AutoWiringService 类中: public class AutoWiringService { private AutoWiringDAO autoWiringDAO111; public void setAutoWiringDAO(AutoWiringDAO autoWiringDAO111) { System.out.println("setAutoWiringDAO"); this.autoWiringDAO111 = autoWiringDAO111; } public void say(String word){ this.autoWiringDAO111.say(word); } }
xml文件中: <bean id="autoWiringDAO111" class="com.imooc.autowiring.dao.AutoWiringDAO"></bean>
我这么设置不能执行,那么需要怎么设置再能执行呢?
public void setAutoWiringDAO111(AutoWiringDAO autoWiringDAO111) {
System.out.println("setAutoWiringDAO");
this.autoWiringDAO111 = autoWiringDAO111;
}
看你自动装配是根据name还是type了,如果是type的话那没什么影响
方法名要和id相对应