UserDaoImpl中的代码,实现对name和age的注入

private String name;
private int age;

public void setName(String name) {
this.name = name;
}

public void setAge(int age) {
this.age = age;
}
applicationContext.xml中的配置


构造器注入将applicationContext.xml中的配置的property换成 constructor-arg,name属性是构造器的形参

posted on 2022-05-18 14:59  cccuuuzzz  阅读(57)  评论(0)    收藏  举报