异常:Bean property 'XXX' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
完整异常信息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cnkiNewInfoService': Injection of resource dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'luceneJournalService' defined in file [D:\Workspaces\eclipse_luna\.metadata\.plugins\org.eclipse.wst.server.core\tmp3\wtpwebapps\sky\WEB-INF\classes\com\ourchem\data\spring\journal-spring.xml]: Error setting property values;
nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'indexWriterJournalCreator' of bean class [com.ourchem.data.lucene.impl.LuceneJournalServiceImpl]: Bean property 'indexWriterJournalCreator' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
分析:
此异常一般出现在spring依赖注入时,如果你用set注入,在spring的XML配置文件中的property属性的name值一定要和你在java中的set方法里的变量一直。
具体举例,解决方法如下: