报错信息
No qualifying bean of type 'xxx.xxx.xxx' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
解决办法
在项目中其他 repository 都能被注入的情况下,可以排除 @ComponentScan、@EnableJpaRepositories、@EntityScan 等扫描操作。
仔细检查发现是因为依赖的 entity 类没有加 @Entity 注解。
另外记得给 @Entity 类的主键字段加上 @Id 注解,否则会报错:No identifier specified for entity 。