Bootstrap

解决springboot整合jpa启动类报错:Not a managed type: class com.example.entity.Xxx

报错信息:

Error creating bean with name 'userRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.example.entity.User

Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.entity.User

 解决方案:

  1. 检查被使用的对应类上是否添加@Entity注解,和生成表的注解及相关属性注解。
  2. 如果不是1方案的问题,可以在启动类中添加扫描使用类所在包的注解@EntityScan(basePackages = “com.example.entity”)试试
;