• Could not create and/or set value back on to object .


    严重: Error building bean
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cn.it.shop.model.Category': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: : No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

    Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {
    }

    严重: Could not create and/or set value back on to object
    java.lang.InstantiationException: cn.it.shop.model.Category
    at java.lang.Class.newInstance(Class.java:359)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:158)
    at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:204)
    at com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:163)

    严重: Exception occurred during processing request: attempt to create saveOrUpdate event with null entity
    java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
    at org.hibernate.event.spi.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:62)
    at org.hibernate.event.spi.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:45)
    at org.hibernate.internal.SessionImpl.update(SessionImpl.java:731)
    at org.hibernate.internal.SessionImpl.update(SessionImpl.java:726)
    at cn.it.shop.service.impl.CategoryServiceImpl.update(CategoryServiceImpl.java:46)

    • 原因:

    struts2的model driven机制采用了反射机制
    反射机制要求用户类必须要有无参构造方法
    当一个类没有构造方法时,java缺省为其加一个无参构造方法
    当你为一个类添加构造方法时,实际上就禁掉了java缺省为类添加无参构造方法这个动作.
    也就是说当你为类添加构造方法后,你的类实际上就没有无参构造方法了,也就不支持反射机制了

  • 相关阅读:
    VMworld 2015 感受:VMware “Ready For Any”
    理解 OpenStack 高可用(HA)(1):OpenStack 高可用和灾备方案 [OpenStack HA and DR]
    Nova 操作汇总(限 libvirt 虚机) [Nova Operations Summary]
    理解 OpenStack 高可用(HA)(5):RabbitMQ HA
    [转]linux sort 命令详解
    [转]linux awk命令详解
    linux sftp 安全文件传输命令
    C++ Jsoncpp源代码编译与解析Json
    linux找不到动态链接库 .so文件的解决方法
    C++ Explicit Constructors(显式构造函数)
  • 原文地址:https://www.cnblogs.com/shanheyongmu/p/5776141.html
Copyright © 2020-2023  润新知