单元测试:java.lang.IllegalStateException: Failed to load ApplicationContext

1 . Cause by:....No identifier specified for entity :org.lee.model.User

     解决:检查数据库实体映射对应的model的主键属性前添加  @Id
               如果主键在数据库中是自动增长的话除了添加  @Id 外还需要添加 @GeneratedValue


2 . Cause by....Repeated column in mapping for entity: org.lee.model.ExamRole column: name

   错因@column重复,复制的时候记得及时改正



3 .Caused by :  org .hibernate.MappingException: Repeated columnin mapping for entity: org.lee.model.ExamTest column: sub_id (should 
           be mappedwith  insert="false" update="false")
 
     错因解决在设置ManyToOne的时候,除了注入的@JoinColumn(name="sub_id")这个字段之外还设置了private String sub_id;以及
               setter,getter方法,造成重复,去掉后者以及后者的setter,getter即可

      


4 . Caused by: org.hibernate.AnnotationException: @OneToOne or@ManyToOne on org.lee.model.UserHibernate.examSubjectHibernate

                     references anunknown entity: org.lee.model.ExamSubjectHibernate

 解决:在model设置了@ManyToOne等映射注解,却没有在model前面添加@Entity以及@Table(name=”Table_name”)




你可能感兴趣的:(springMVC,java,java-web,springmvc,javascript,单元测试,entity)