提问者:小点点

Spring boot Jpa不支持Spring batch和spring integration


我正在使用Spring批。我需要添加一些jpa存储库。所以之前我使用的是工作正常的JDBCTemplate。

但是当我开始使用 JPA 时,Spring 引导应用程序找不到存储库。哪些在那里。

@Autowired
ClassLevelConfigRepo clcr;

我检查了这些东西作为最佳实践。

  1. 在springBoot应用程序类中添加了@EnableJpaRepositories
  2. @Repostiories添加到存储库接口。
  3. 使用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 ```



共1个答案

匿名用户

当您使用Spring Data Jpa处理这些基本要点时,您还应该跟踪以下要点。

  1. 您已在 POM 中添加了 spring-boot-starter-data-JPA.xml
  2. 您已在应用程序包的一个级别下添加了实体存储库包。
  3. 如果包处于同一级别,则应在注释中指定确切的包详细信息。 在您的情况下,它应该是这样的:
@EnableJpaRepositories("com.cloudtask.batchconfig.repo")
@EntityScan(basePackages = {"com.cloudtask.batchconfig.entity"})

祝您编程愉快!