@Required
public void setInjectionDAO(InjectionDAO injectionDAO) {
this.injectionDAO = injectionDAO;
}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'injectionServiceImpl' defined in file [D:\Myeclipse\Workspace\SpringCourse\bin\test8\InjectionServiceImpl.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Property 'injectionDAO' is required for bean 'injectionServiceImpl'
既然配置required ,类的实例化应该是有先后顺序的吧。
@Required注解适用于bean属性的setter方法并且它指示,受影响的bean属性必须在配置时被填充在XML配置文件中,否则容器将抛出BeanInitializationException.
也就是说,你要用@Required注解setter方法,就必须在Spring 配置文件中设置该属性
'injectionDAO'这个Bean名字匹配吗?