我刚刚使用Spring Batch框架创建了一个批处理作业,但是我没有运行CREATE SQL的数据库权限.当我尝试运行批处理作业时,我在框架尝试创建TABLE_BATCH_INSTANCE时遇到错误.我试着禁用
<jdbc:initialize-database data-source="dataSource" enabled="false">
...
</jdbc:initialize-database>
Run Code Online (Sandbox Code Playgroud)
但在我尝试之后我仍然遇到了错误
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Run Code Online (Sandbox Code Playgroud)
无论如何可以禁用SQL,我只想测试我的读写器和处理器正常工作.
我正在尝试配置 Spring Batch 以使用 PostGres DB。我在我的build.gradle.kts文件中包含了以下依赖项:
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.postgresql:postgresql")
Run Code Online (Sandbox Code Playgroud)
我application.yml的 SpringBatch 模块包含以下内容:
spring:
datasource:
url: jdbc:postgresql://postgres:5432/springbatchdb
username: postgres
password: root
driverClassName: org.postgresql.Driver
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml
postgres:
restart: always
image: postgres:12-alpine
container_name: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=root
- POSTGRES_DB=springbatchdb
ports:
- "5432:5432"
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试添加数据文件时,我在 SpringBatch Docker 容器和 PostGres 容器的日志中看到以下错误:
春季批次:
<<< Exception in method: org.meanwhileinhell.spring.batch.server.SpringBatchController.handle Error Message: PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]; nested …Run Code Online (Sandbox Code Playgroud)