zoukankan      html  css  js  c++  java
  • 解决Bean property ** is not writable or has an invalid setter method

    struts2+spring真让人纠结……

    遇到了Bean property ** is not writable or has an invalid setter method这样的错误  正好找到个类似的解答

    用SSH2框架,为某Action注入Bo时出现NotWritablePropertyException异常.当时是用同事已写好的名字cMsgbo.但启动tomcat时总抛出NotWritablePropertyException异常.详细异常信息如下:

    Error creating bean with name '/count' defined in ServletContext resource [/WEB-INF/classes/kingtoonApplicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'cMsgbo' of bean class [com.kingtoon.count.struts.action.CountAction]: Bean property 'cMsgbo' is not writable or has an invalid setter method. Did you mean 'CMsgbo'?
    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'cMsgbo' of bean class [com.kingtoon.count.struts.action.CountAction]: Bean property 'cMsgbo' is not writable or has an invalid setter method. Did you mean 'CMsgbo'?

    这个错误信息最后问我是不是CMsgbo.于是乎我就随便换成一名字,比如comBo.然后再次启动Tomcat,服务器顺利启动.

    总结:可能Spring会检查当前所起的名字是不是符合其规范以致可以认出是个什么东西来.如果起的名字不是很明确的话,那spring会给你一个异常,提示你换个名字吧,当前这个名字我认不出来.照她说的做就没问题了.

    转自 http://hi.baidu.com/kingtoon_go/blog/item/8bdf6b38416f462796ddd878.html

    我自己用的时候是在Action中实例化接口的时候拼写不一致导致的

    public class BtnClickAction extends ActionSupport{
    	IBtnClickSumService btnClickSumService;

    之前写成

    IBtnClickSumService btnClickService;

    实例名少了几个字母就不行了,

    擦……

  • 相关阅读:
    Mysql 去重
    深入理解ob_flush和flush的区别
    Yii2 基础模板前后台登录分离
    Yii2 登录报错
    使用 php 内部web服务器
    SQL 分组后,获取每组中的最大值对应的数据
    跨域访问解决方案
    Spring Boot对静态资源的映射规则
    Spring Boot项目的探究
    Spring Boot项目的不同启动方式
  • 原文地址:https://www.cnblogs.com/windows/p/2332565.html
Copyright © 2011-2022 走看看