j2EE編寫時易錯問題。

org.springframework.web.context.support.XmlWebApplicationContext.refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'user_service' defined in class path resource [META-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'recordDao' of bean class [com.jixiang.service.impl.UserServiceImpl]: Bean property 'recordDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

28-Dec-2017 13:48:46.127 嚴重 [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.ContextLoader.initWebApplicationContext Context initialization failed

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'user_service' defined in class path resource [META-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'recordDao' of bean class [com.jixiang.service.impl.UserServiceImpl]: Bean property 'recordDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1568)

意思就是在com.jixiang.service.impl.UserServiceImpl這個類中沒有找到recordDao,或者沒有recordDao的setter方法。

但是你在Spring的applicationContext.xml配置中又加入了這個配置

<bean id="managerTemplate" abstract="true" lazy-init="true"
     
p:mangerDao-ref="managerDao"
     
p:userDao-ref="userDao"
   
 p:recordDao-ref="recordDao"
     
/>
<bean id="user_service"
     
class="com.jixiang.service.impl.UserServiceImpl"
     
parent="managerTemplate"/><!--class的類名一定要對-->


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章