zoukankan      html  css  js  c++  java
  • 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缺省为类添加无参构造方法这个动作.
    也就是说当你为类添加构造方法后,你的类实际上就没有无参构造方法了,也就不支持反射机制了

  • 相关阅读:
    华为精益敏捷专家:DevOps转型中的那些坑
    极致进化-敏捷进化型企业的未来畅想
    DevOps的工程化
    京东精益敏捷教练分享:敏捷助力产品创新!
    敏捷开发进度管理之燃尽图
    手把手教你进行Scrapy中item类的实例化操作
    手把手教你使用ADB卸载手机内置App软件
    手把手教你使用Python生成图灵智能小伙伴,实现工作助手/闲聊功能
    手把手教你利用Pyecharts库对IP代理数据进行数据可视化分析
    手把手教你使用Python爬取西刺代理数据(下篇)
  • 原文地址:https://www.cnblogs.com/shanheyongmu/p/5776141.html
Copyright © 2011-2022 走看看