zoukankan      html  css  js  c++  java
  • 缺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?


    解决办法:

    看错误,从最底层看,最后一个cause by,因为如果最底层出错,上面的也会出错,因为代码是从最底层往上注入的,下面的错了,上面的也就错了,所以先看最底层的。

    看到最底层,发现,UserService类中有无效的setter方法,查看UserService,发现里面的set方法确实有问题,忘记写参数了。

    一般,get和set方法的生成,最好自动生成,因为自己写的话,容易出错。自动生成的办法: 在代码空白处右击-Source-Generate Getters and Setters,然后选择需要生成的方法即可。

  • 相关阅读:
    Element没更新了?Element没更新,基于El的扩展库更新
    MVC与Validate验证提示的样式修改
    封装两个简单的Jquery组件
    VS20XX-Add-In插件开发
    CentOS7 配置环境
    PHP Laravel 5.4 环境搭建
    【设计经验】5、Verilog对数据进行四舍五入(round)与饱和(saturation)截位
    【设计经验】4、SERDES关键技术总结
    【高速接口-RapidIO】6、Xilinx RapidIO核仿真与包时序分析
    【高速接口-RapidIO】5、Xilinx RapidIO核例子工程源码分析
  • 原文地址:https://www.cnblogs.com/cyy-13/p/5848254.html
Copyright © 2011-2022 走看看