Loading

No identifier specified for entity

org.hibernate.AnnotationException: No identifier specified for entity

异常信息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in
 class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of ini
t method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity

异常原因

实体类中需要有唯一标识符,需要指定主键

解决

在你实体类的主键上加上下面的两个注解即可。

    @Id
    @GeneratedValue
    private Long id;
posted @ 2019-07-26 11:21  Hoonick  阅读(397)  评论(0编辑  收藏  举报