您的位置:首页 > 运维架构

Bean property 'esyerDao' is not writable or has an invalid setter method. Does the parameter type of

2015-02-04 22:37 369 查看
今天调试程序的时候偶然出现了

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeServiceDest' defined in ServletContext resource 
[/WEB-INF/web-application-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: 
Invalid property 'esyerDao' of bean class [com.service.EmployeeServiceImpl]:

 Bean property 'esyerDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


出现Bean property 'esyerDao' is not writable or has an invalid setter method错误后,感觉莫名其妙

因为esyerDao 这个dao 注入到了其它两个bean里面,都可以正常使用,但是就是到 employeeServiceDest 里面就出错了。

百思不得其解啊,查找过网上的各种这类错误的解决方法,都不奏效。

最后找到了原因,感觉也是吃一堑长一智啊。

系统里面的class文件以前都是直接丢到WEB-INF/classes 目录下面的,后来将class文件打为jar包,丢到了WEB-INF/lib 目录下面。
出问题的这个bean 就是因为 同时在WEB-INF/classes 和 WEB-INF/lib 下面的jar包中同时存在了该class文件。

导致WEB-INF/lib下面jar包中的有属性注入的class文件一直被直接放到WEB-INF/classes 下面的class覆盖。

另一个同时前几天调试过该class文件,但是他的class文件放在了WEB-INF/classes下面,他的class中没有esyerDao的注入。

我在 WEB-INF/lib 下面jar包中的有属性注入的class文件一直被直接放到WEB-INF/classes 下面的class覆盖,导致了一直注入失败。

记录下来,希望看到的朋友,不要再犯类似的错误。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐