j2EE编写时易错问题。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的类名一定要对-->


以上是关于j2EE编写时易错问题。的主要内容,如果未能解决你的问题,请参考以下文章

Java代码编写时易犯错误

使用 Python 代码片段编写 LaTeX 文档

编写代码片段的更简洁的方法

高薪前端开发都会巧妙的躲过这10个易错点!

我们可以在活动 xml 中编写 UI 以及在片段 xm 中编写 UI 吗?

JS的易错代码