【问题标题】:Spring batch try to create tableSpring批处理尝试创建表
【发布时间】:2021-10-16 00:00:48
【问题描述】:

我在 Spring Boot 应用程序 (2.5.3) 中使用 Spring Batch。

在我的属性中,我放了这两行以避免创建数据库表

spring.batch.jdbc.initialize-schema=never
spring.batch.initialize-schema=never

在我的 Config 类中,我有

@Bean
public Job lastConsentBatchJob() {
    return this.jobBuilderFactory.get("lastBatchJob")
            .incrementer(new RunIdIncrementer())
            .flow(lastConsentBatchStep())
            .end()
            .build();

}

@Bean
public Step lastConsentBatchStep() {
    return this.stepBuilderFactory.get("lastBatchJob").<LastDto, LastDto>chunk(1)
            .reader(reader())
            .writer(writer(null)).build();
}

为什么当我午餐应用程序时,春天启动这个查询

SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?

【问题讨论】:

  • Spring Batch 默认使用数据库来存储有关作业执行的信息。您无法删除它,但可以使用 MapJobRepository。这就是你要找的吗?

标签: spring-boot spring-batch


【解决方案1】:

spring.batch.jdbc.initialize-schema=never 阻止启动为 Spring 初始化表创建的脚本

这个查询不是这个脚本的一部分,它试图在假定创建的表中检索事务信息

可以使用ResourcelessTransactionManager 禁用事务管理,但不建议用于生产环境

【讨论】:

    猜你喜欢
    • 2016-01-19
    • 2020-10-24
    • 2019-05-24
    • 1970-01-01
    • 2017-08-14
    • 2015-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多