Heim  >  Fragen und Antworten  >  Hauptteil

Der Spring-Batch-Job startet nicht in der Entwicklungsumgebung

Ich verwende Spring Spring-Boot-Starter-Batch 2.7.9 mit MySQL DB als Datenquelle. Ich habe ein seltsames Problem: Der Batch-Job wird lokal ausgeführt, kann jedoch nicht in der Entwicklungsumgebung (Kubernetes) gestartet werden, mit der folgenden Ausnahme:

Exception while starting job
    org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT into BATCH_JOB_EXECUTION_PARAMS(JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING) values (?, ?, ?, ?, ?, ?, ?, ?)]; SQL state [HY000]; error code [3098]; The table does not comply with the requirements by an external plugin.; nested exception is java.sql.SQLException: The table does not comply with the requirements by an external plugin.

Jobs werden über die Rest-API ausgelöst, die zwei Jobparameter bereitstellt: string und datetime.

Beispielparameter:

{
    "idType" : "ALL",
    "triggerTime": "2023-03-16T19:54:18.262Z" 
}

Ein Unterschied zwischen meiner lokalen Datenbank und meiner Entwicklungsdatenbank könnte der Replikationsfaktor sein. Die Entwicklungsdatenbank ist mit 3 Replikaten konfiguriert, wohingegen ich lokal nur eines habe. Könnte dies die Ursache für diese Ausnahme sein? Wie kann ich dieses Problem lösen? TIA.

P粉517814372P粉517814372410 Tage vor542

Antworte allen(1)Ich werde antworten

  • P粉166675898

    P粉1666758982023-09-07 00:26:00

    您需要自定义 Spring Batch 元表的定义,以便每个表都有一个主键。

    默认情况下,MySQL 接受没有主键的表。但在任何使用 MySQL 复制的设置中,没有主键的表要么根本不起作用(如您的组复制情况),要么会导致日后的操作难题。

    根本原因是 Spring Batch 架构的 DDL 包含的索引数量非常有限。这是故意的,因为索引的最佳方法在很大程度上取决于特定的用例: https://docs.spring.io/spring-batch/docs/4.3.8/reference/html/schema-appendix.html#recommendationsForIndexingMetaDataTables

    Antwort
    0
  • StornierenAntwort