2013年11月8日

使用lookup-method解决singleton bean依赖prototype bean的问题

摘要: 在Spring里面,当一个singleton bean依赖一个prototype bean,那么,因为singleton bean是单例的,因此prototype bean在singleton bean里面也会变成单例,例如:public class Main{ private Man man; //这里注入一个prototype的Man实例 public void setMan(Man man) { this.man= man; } public Man getMan() { return man; }}配置文件: 如果我为Main创建一个单例bean,那么当我注入Man实... 阅读全文

posted @ 2013-11-08 14:32 heartstage 阅读(489) 评论(0) 推荐(0)

导航