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;