如何在Spring 5.0.1中禁用Spring Batch元数据

huangapple go评论63阅读模式
英文:

How to Disable Spring Batch Meta Data in spring 5.0.1

问题

I googled a lot and trying to follow this doc https://docs.spring.io/spring-batch/docs/5.0.1/reference/html/whatsnew.html#whatsNew

但是找不到禁用Spring Batch元数据的方法。

即使我尝试不使用@EnableBatchProcessing,仍然出现以下错误:

for servlet [dispatcherServlet] in context with path [] threw
exception [Request processing failed:
org.springframework.jdbc.BadSqlGrammarException;
PreparedStatementCallback; bad SQL grammar [SELECT JOB_EXECUTION_ID,
PARAMETER_NAME, PARAMETER_TYPE, PARAMETER_VALUE, IDENTIFYING from
BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?]] with root
cause java.sql.SQLSyntaxErrorException: Unknown column
'PARAMETER_NAME' in 'field list'

如果有任何代码参考或教程,请建议。

英文:

I googled a lot and trying to follow this doc https://docs.spring.io/spring-batch/docs/5.0.1/reference/html/whatsnew.html#whatsNew

But not able to find a way to disable spring batch meta data.

Even I tried not to use @EnableBatchProcessing but still getting this err:

> for servlet [dispatcherServlet] in context with path [] threw
> exception [Request processing failed:
> org.springframework.jdbc.BadSqlGrammarException:
> PreparedStatementCallback; bad SQL grammar [SELECT JOB_EXECUTION_ID,
> PARAMETER_NAME, PARAMETER_TYPE, PARAMETER_VALUE, IDENTIFYING from
> BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?]] with root
> cause java.sql.SQLSyntaxErrorException: Unknown column
> 'PARAMETER_NAME' in 'field list'

If there is any code reference or tutorial please suggest.

答案1

得分: 1

你无法“禁用”元数据。Job 总是需要一个 JobRepository 来报告其元数据(除非你自己实现了 Job 接口,但如果决定使用 Spring Batch,这并不是首要目标)。

从版本5开始,Spring Batch只提供基于JDBC的JobRepository实现。内存中的基于Map的实现已被移除。因此,你必须使用JDBC实现(这是默认的,需要JDBC数据源),或者自己提供一个JobRepository的自定义实现。

在使用默认的基于JDBC的JobRepository的情况下,数据源可以是内存中的一个(比如H2、HSQLDB等)。

英文:

You can't "disable" metadata. A Job always requires a JobRepository to report its meta-data to (unless you implement the Job interface yourself, which is not the goal in the first place if you decide to use Spring Batch).

Now starting from v5, Spring Batch only provides a JDBC based implementation of the JobRepository. The in-memory Map-based implementation was removed. Therefore, you have to use the JDBC implementation (which is the default and which requires a JDBC datasource), or provide a custom implementation of JobRepository yourself.

In the case of using the default JDBC based JobRepository, the datasource could be an in-memory one (like H2, HSQLDB, etc).

huangapple
  • 本文由 发表于 2023年5月14日 05:52:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245029.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定