Spring Batch Framework - Auto create Batch Table

后端 未结 9 1559
广开言路
广开言路 2020-12-01 12:02

I just created a batch job using Spring Batch framework, but I don\'t have Database privileges to run CREATE SQL. When I try to run the batch job I hit the error while the f

相关标签:
9条回答
  • 2020-12-01 12:50

    When running with Spring Boot:

    Running with Spring Boot v1.5.14.RELEASE, Spring v4.3.18.RELEASE

    This should be enough:

    spring:
        batch:
            initializer:
                enabled: false
    

    The initialize-schema did not work for this Spring boot version. After that I was able to copy the SQL scripts from the spring-core jar and change the table capitalization since this was my issue with the automatic table creation under Windows/Mac/Linux.

    0 讨论(0)
  • 2020-12-01 12:53

    this works for me: Spring boot 2.0

      batch:
            initialize-schema: never
            initializer:
                enabled: false
    
    0 讨论(0)
  • 2020-12-01 12:54

    Seems silly, but someone can have the same problem.

    I was receiving this error after drop all tables from a database. When I tried to start the Spring Batch, I received the error:

    bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]

    and:

    Invalid object name 'BATCH_JOB_INSTANCE'

    This happened to me because I drop the tables without restart the service. The service was started and receive the database metadata with the Batch tables on the database. After drop them and not restart the server, the Spring Batch thought that the tables still exists.

    After restart the Spring Batch server and execute the batch again, the tables were created without error.

    0 讨论(0)
提交回复
热议问题