使用Spring 的xml 方式装配Bean,启动项目提示错误:
Error creating bean with name 'finalreportservice' defined in ServletContext resource [/WEB-INF/spring-bean.xml]:
Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'templateFieldValueDao' of bean class
[com.gettec.lims.core.report.service.impl.FinalReportServiceImpl]:
Bean property 'templateFieldValueDao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
错误原因:
第一个Bean (此处即finalreportservice)代码中去掉了templateFieldValueDao 属性,但spring 装配的xml 中finalreportservice 忘了去掉对应的templateFieldValueDao 的bean。
解决:
去掉xml 中该属性依赖。
体会:
最好用自动装配,不用xml 方式。