Spring3.0框架中依赖注入主要有几种方式?
展开全部
3种方法
1。构造器注入
public class xx {
private Manager manage;
public xx(Manager manage){
this.manage= manage;
}
}
2.setter 方法注入
public class xx {
private Manager manage;
public void setManager(Manager manage){
this.manage= manage;
}
}
3.接口注入
public interface Manager{
public void manage(Business business);
}
public class xx {
private Business business;
public void manage(Business business){
this.business = business;
}
}
1。构造器注入
public class xx {
private Manager manage;
public xx(Manager manage){
this.manage= manage;
}
}
2.setter 方法注入
public class xx {
private Manager manage;
public void setManager(Manager manage){
this.manage= manage;
}
}
3.接口注入
public interface Manager{
public void manage(Business business);
}
public class xx {
private Business business;
public void manage(Business business){
this.business = business;
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询