Error creating bean with name 'entityManagerFactory' defined in class path resource 报错

Error creating bean with name ‘entityManagerFactory’ defined in class path resource : Invocation of init method failed解决方案

这是我在学Spring data jpa多数据源时候的问题,这个问题真的困扰我很好几天了
问题原因:创建实体类失败,即我们在创建实体类时主键导包导错了,正确的导包:

package wen.datademo.domain;

import lombok.Data;

import javax.persistence.*;

@Entity
@Table(name = "t_user")
@Data
public class User {

    @Id
    @Column(name = "t_id")
    @GeneratedValue
    private Long id;

    @Column(name = "t_name")
    private String name;

    @Column(name = "t_age")
    private int age;

    @Column(name = "t_address")
    private String address;

    @Column(name = "t_pwd")
    private String pwd;
}

而我们很多时候容易导入“import org.springframework.data.annotation.Id;”的包,把这个去掉就可以了

你可能感兴趣的:(Spring,Boot学习笔记,Java,后端,问题解决)