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,然后选择需要生成的方法即可。

  • 相关阅读:
    C# 导出 Excel 自定义输出格式
    ONE路由协议模块分析与应用
    2440(ARM9) L3G4200D ADXL345 裸机程序
    C# SerialPort.close() bug解决方法
    C++ Primer 第五章 表达式
    C++ Primer 第一章 快速入门
    C++ Primer 第二章 变量和基本类型
    虚拟机virtualbox中挂载新硬盘
    C++ Primer 第四章 数组与指针
    C++ Primer 第三章 标准库类型
  • 原文地址:https://www.cnblogs.com/cyy-13/p/5848254.html
Copyright © 2011-2022 走看看