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