admin管理员组

文章数量:1642166

完整错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'universityRepository' defined in com.gaagle.gaagle.repository.UniversityRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.gaagle.gaagle.vo.ResultVO

这种情况下一般都是实体类@Id注解弄错了(用成了Spring那个)或者数据库表的主键搞成了自增(据说会,没求证)或者实体类没有主键。但是经过反复排查都不是这些原因,而且报错的是一个非实体类ResultVO,我百思不得其解,为什么一个和JPA无关的类会引起JPA报错(其实这就是错误的原因)直到我发现:

 因为JPA必须要给实体指定主键,删掉@Entity注解即可,其实这也属于没有主键那类错误。

本文标签: 报错jpaSpringBootidentifierentity