Spring Bean BeanCreationException,NotWritablePropertyException异常
来源:互联网 发布:积分编排软件 编辑:程序博客网 时间:2024/05/21 10:18
错误现象
aused by: org.springframework.beans.NotWritablePropertyException:
Invalid property 'userServiceRemote' of bean class [com.xxx.web.score.ScoreAction]: Bean property 'userServiceRemote' is not writable or has an invalid setter method.
Does the parameter type of the setter match the return type of the getter?at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:925) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:82) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:62) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1489) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.0.4.RELEASE.jar:4.0.4.RELEASE]at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973) ~[spring-context-4.0.4.RELEASE.jar:4.0.4.RELEASE]at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:161) ~[xwork-core-2.3.32.jar:2.3.32]at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:178) ~[xwork-core-2.3.32.jar:2.3.32]at com.opensymphony.xwork2.factory.DefaultActionFactory.buildAction(DefaultActionFactory.java:22) ~[xwork-core-2.3.32.jar:2.3.32]at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:148) ~[xwork-core-2.3.32.jar:2.3.32]at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:298) ~[xwork-core-2.3.32.jar:2.3.32]
Invalid property 'userServiceRemote' of bean class [com.xxx.web.score.ScoreAction]: Bean property 'userServiceRemote' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?翻译下:bean类[com.xxx.web.score.ScoreAction]的属性“userServiceRemote”属性无效:Bean属性“userServiceRemote”不可写或具有无效的setter方法。 setter的参数类型是否匹配getter的返回类型?错误原因:
要先说下事情的起因了,类A中需要把类B注入成为private属性,
配置如下:
后来,ScoreAction这个类又不需要userServiceRemote这个属性了,我就把private ......这句注释掉了.
spring配置文件,依然有这句话,我知道.
<property name="userServiceRemote" ref="userServiceRemote" />
但我想,这里声明了属性, 但我不实际使用,应该没有问题, Too young, too simple,
访问时,接口直接提示,服务器异常, 让人摸不着头脑,后来,在本机开发环境,编译,部署,才看到上面的BeanCreationException,NotWritablePropertyException异常
信息.
解决办法
把ScoreAction类中,private IUserServiceRemote userServiceRemote;删掉,
把配置文件里的<property name="userServiceRemote" ref="userServiceRemote" />也删掉.
其他说明
1.修改代码后,一定要先在本机开发环境,编译代码,部署项目,启动tomcat,访问接口,试一试, 对自己的代码100%自信,会蒙蔽一些细节错误.
联调换句那一句服务器异常,看我也是摸不着头脑.
2.当A类不想再使用某个属性B时,把相关配置,引用都删掉,只是注释掉,会行程干扰,
感觉写的不够深入,请见谅.
阅读全文
0 0
- Spring Bean BeanCreationException,NotWritablePropertyException异常
- Spring 框架:org.springframework.beans.factory.BeanCreationException/NotWritablePropertyException
- NotWritablePropertyException异常
- 关于spring中抛出NotWritablePropertyException异常的问题
- Spring ...BeanCreationException: Error creating bean with name 'sqlSessionFactoryWrite'
- spring beanCreationException
- spring bean注入异常
- SSH框架中报错org.springframework.beans.factory.BeanCreationException或者NotWritablePropertyException
- Spring中BeanCreationException异常::0formul unbound in pointcut
- Spring Boot异常:BeanCreationException:Injection of autowired dependencies failed;
- Spring Boot异常:BeanCreationException:Injection of autowired dependencies failed;
- spring启动异常:org.springframework.beans.factory.BeanCreationException
- NotWritablePropertyException
- 异常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletCo
- springMVC注解异常org.springframework.beans.factory.BeanCreationException: Error creating bean with name
- spring @Autowired加载bean异常
- 解决org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.spring
- spring 错误(org.springframework.beans.NotWritablePropertyException)
- ELK-01
- 2017 Multi-University Training Contest
- java面试Linux常用命令使用方法大全
- 程序员的职业素养_心得体会
- node.js中使用http模块发送请求时的一个小错误
- Spring Bean BeanCreationException,NotWritablePropertyException异常
- 根据经纬度计算多边形的面积(calculcate polygon's area by lon and lat)
- 【ssm】ssm的maven工程整合(超详细步骤)
- error LNK2001: 无法解析的外部符号 _AVIStreamGetFram
- HDU 3308 LCIS(线段树的区间合并)
- 利用正则表达式获取syslog
- Visual Studio 2015+MySQL 5.7环境搭建
- ELK-02
- 字符数组转换为字符串