Run Program error:
Context initialization failed
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' Xxxxdao ' defined in file [d:\ Workspace\xxx\xxx\webapp\web-inf\classes\com\xxx\xxx\xxx\config\spring-webmanage.xml]: Cannot Resolve reference to The bean ' sessionfactory ' while the setting bean property ' sessionfactory '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sessionfactory ' defined in URL [Jar:file:/d:/workspace/xxx/xxx/webapp/web-inf/lib/xxx.jar!/spring-base.xml]: Invocation of Init method failed; Nested exception is org.hibernate.MappingException:Composite-id class must implement Serializable:Com.xxx.xxx.xxx.pojo.Organization
At Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:328)
At Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:106)
......
The most important error in this section is "Composite-id class must implement Serializable: "
is because it is defined as a federated primary key in the mapping file. Hbm.xml, that is, <composite-id> <composite-id>
<key-property name= "pid" type= "Java.lang.String" >
<column name= "PID"/>
</key-property>
<key-property name= "CID" type= "java.lang.String" >
<column name= "CID"/>
</key-property>
</composite-id>
Solution:
When using a federated primary key, the Bean class must be serialized
import java.io.Serializable;
Public Classbean implements Serializable {
private static final long serialversionuid = 1L;
}