在springboot中整合JPA Error creating bean with name 'entityManagerFactory'

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 init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.mysql.demo.mysqltest.model.User

解决办法在User实体类中解决就行了!!!!

@Entity
@Table(name = "sys_user")
public class User implements Serializable{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY) //主键自增
    //@GenericGenerator(name="system-id", strategy = "uuid.hex")
    @Column(name = "USERID")
    private int userId;
    @Column(name = "USERNAME")
    private String userName;
    @Column(name = "SEX")
    private int sex;
    @Column(name = "DEGEREE")
    private Double degeree;
    @Column(name = "ORGID")
    private int orgId;

解决办法:实体类@Entity @Id 等导包都是:

import javax.persistence.*;

@Id 不能导包:

import org.springframework.data.annotation.Id;
发布了246 篇原创文章 · 获赞 12 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_41987908/article/details/105471053
今日推荐