spring中怎么通过构造方法注解给一个对象注入对象??

2024-11-28 10:39:54
推荐回答(2个)
回答1:

#MyService.java
public class MyService(){
public MyDao dao ;
public MyService(MyDao dao){
super();
this.dao=dao;
}
}
#beans.xml



回答2:

@Autowired
public MyService(MyDao dao){

}