為什么使用Required注解會有異常?
@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'
2019-08-21
既然配置required ,類的實例化應該是有先后順序的吧。
2016-12-02
@Required注解適用于bean屬性的setter方法并且它指示,受影響的bean屬性必須在配置時被填充在XML配置文件中,否則容器將拋出BeanInitializationException.
也就是說,你要用@Required注解setter方法,就必須在Spring 配置文件中設置該屬性
2016-10-28
'injectionDAO'這個Bean名字匹配嗎?