packagecn.csdn.hr.service;publicclassGeetingServiceBeanimplementsGreetingService{privateintgreeting;publicvoidsetGreeting(intgreeting){this.greeting=greeting;}publicGeeti...
package cn.csdn.hr.service;
public class GeetingServiceBean implements GreetingService {
private int greeting;
public void setGreeting(int greeting) {
this.greeting = greeting;
}
public GeetingServiceBean(int greeting) {
this.greeting = greeting;
}
public GeetingServiceBean() {
}
public void sayGeeting() {
System.out.println(greeting);
}
}
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
用set方式不会报错,但是用构造器缺报错了:Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'geetingServiceBean' defined in class path resource [applicationContext.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
展开