首页 > 代码库 > 解决Caused by: org.springframework.beans.NotWritablePropertyException总结

解决Caused by: org.springframework.beans.NotWritablePropertyException总结

       提出:今天做springxml的setter注入属性demo出现的属性无法注入的bug.

      错误信息如下:

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘27‘ of bean class [com.wg.xml_setter.Person]: Bean property ‘27‘

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

        解决思路:

                            (1):一般属性的正确的getter和setter的第二个字母是大写,有时利用快捷键生成时第二个字母是小写,故无法注入.

                                           属性编写规范:忌属性名在合成单词时都使用大写

                            (2):检查xml配置文件,我的错误就是手残写错地方导致的

                                  技术分享

 

                                       这里我把本该写age的填了值

解决Caused by: org.springframework.beans.NotWritablePropertyException总结