首页 > 代码库 > 缺setter异常
缺setter异常
严重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘urlMapping‘ defined in ServletContext resource [/WEB-INF/web-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userAction‘ defined in ServletContext resource [/WEB-INF/web-config.xml]: Cannot resolve reference to bean ‘userService‘ while setting bean property ‘userService‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService‘ defined in ServletContext resource [/WEB-INF/service-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userAction‘ defined in ServletContext resource [/WEB-INF/web-config.xml]: Cannot resolve reference to bean ‘userService‘ while setting bean property ‘userService‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService‘ defined in ServletContext resource [/WEB-INF/service-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService‘ defined in ServletContext resource [/WEB-INF/service-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
2016-9-6 16:42:53 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /spmvc01 threw load() exception
org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ 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 ‘urlMapping‘ defined in ServletContext resource [/WEB-INF/web-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userAction‘ defined in ServletContext resource [/WEB-INF/web-config.xml]: Cannot resolve reference to bean ‘userService‘ while setting bean property ‘userService‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService‘ defined in ServletContext resource [/WEB-INF/service-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userAction‘ defined in ServletContext resource [/WEB-INF/web-config.xml]: Cannot resolve reference to bean ‘userService‘ while setting bean property ‘userService‘; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService‘ defined in ServletContext resource [/WEB-INF/service-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService‘ defined in ServletContext resource [/WEB-INF/service-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
2016-9-6 16:42:53 org.apache.catalina.core.StandardContext loadOnStartup
严重: Servlet /spmvc01 threw load() exception
org.springframework.beans.NotWritablePropertyException: Invalid property ‘userDao‘ of bean class [com.sxt.service.UserService]: Bean property ‘userDao‘ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
解决办法:
看错误,从最底层看,最后一个cause by,因为如果最底层出错,上面的也会出错,因为代码是从最底层往上注入的,下面的错了,上面的也就错了,所以先看最底层的。
看到最底层,发现,UserService类中有无效的setter方法,查看UserService,发现里面的set方法确实有问题,忘记写参数了。
一般,get和set方法的生成,最好自动生成,因为自己写的话,容易出错。自动生成的办法: 在代码空白处右击-Source-Generate Getters and Setters,然后选择需要生成的方法即可。
缺setter异常
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。