我正在使用Spring批。我需要添加一些jpa存储库。所以之前我使用的是工作正常的JDBCTemplate。
但是当我开始使用 JPA 时,Spring 引导应用程序找不到存储库。哪些在那里。
@Autowired
ClassLevelConfigRepo clcr;
我检查了这些东西作为最佳实践。
@EnableJpaRepositories
。@Repostiories
添加到存储库接口。JpaRepository扩展接口
但是我仍然在误差之下。
com.cloudtask.batchconfig.util.LhmUtility 中的字段 clcr 需要一个类型为“com.cloudtask.batchconfig.repo.ClassLevelConfigRepo”的 bean,但找不到。
我尝试检查pom中的所有依赖项.xml这是按照建议的。我在数据库中正确定义了所有表。
编辑 1:Spring启动应用程序注释
@SpringBootApplication
@ComponentScan({"com.cloudtask"})
@EnableAsync
@IntegrationComponentScan({"com.cloudtask"})
@EnableIntegrationManagement(defaultLoggingEnabled = "true")
@EnableJpaRepositories
@EntityScan
public class imclassApplication ```
当您使用Spring Data Jpa处理这些基本要点时,您还应该跟踪以下要点。
spring-boot-starter-data-JPA
.xml实体
和存储库
包。@EnableJpaRepositories("com.cloudtask.batchconfig.repo")
@EntityScan(basePackages = {"com.cloudtask.batchconfig.entity"})
祝您编程愉快!