本文主要是介绍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")@GeneratedValueprivate 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;”的包,把这个去掉就可以了
这篇关于Error creating bean with name 'entityManagerFactory' defined in class path resource 报错的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!