spring.job.启用: true causing junit jobs to run twice

标签 spring spring-boot spring-batch

我有一个 Spring Boot Spring Batch 项目。以下设置在我的application.yml中

# Spring Framework Standard Properties
spring:
  batch:
    job.enabled: true

当我将此设置设置为 true 时,如上所述,它会导致我的 junit 测试在每次启动单元测试时运行两次。

当我将设置更改为 false 时,我的 junit 测试会在启动相同的单元测试时运行一次。

几个问题...

我不是 100% 清楚这个设置是什么。谁能告诉我更多信息。

还有什么我可以在我的单元测试中放入任何东西来将其更改为 false 仅用于我的单元测试。

最佳答案

来自the official documentation:

By default a Runner will be created and all jobs in the context will be executed on startup.

Disable this behavior with spring.batch.job.enabled=false.

关于spring.job.启用: true causing junit jobs to run twice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38520625/

相关文章:

java - 使用 POJO 作为 Spring Redis 缓存的键时,如何获取所有键?

Spring Boot 嵌入式 Tomcat 未在 ApplicationListener 中加载外部属性文件

java - Spring Batch 等待平面文件中的行

java - Spring boot 1.5.2 未部署在 Openshift Tomcat 7(JBoss EWS 2.0) 中

spring - Spring 中的异步记录器

java - 我可以在 Spring JUnit 测试中使用 @Import 吗?

java - 如何使用 spring data、hibernate 为映射实体创建自定义查询?

java - 使用 JOINED 继承策略并设置 spring.jpa.properties.hibernate.jdbc.batch_size 时部分保存实体

spring-batch - 在 spring 批处理 itemReader 中从流而不是文件中读取

java - 如何测试 "Too Many Files Open"问题