使用MySQL DB的spring boot批处理始终将主键生成为0

时间:2018-05-26 01:20:26

标签: java mysql spring-boot spring-data-jpa spring-batch

我在MySQL DB中使用Spring启动批处理(spring-boot-starter-parent版本2.0.2)。早些时候,我使用Spring引导批处理(版本1.5.x)与相同的MySQL DB,它工作正常。

现在我可以看到它为每个应用程序生成的主键为0,表示所有元数据表,例如:enter image description here,它失败,因为MYSQL抛出错误" com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException :重复输入' 0'关键' PRIMARY'"

请帮忙建议不要自动增加PRIMARY KEY。

如果我创建新的MySQL数据库,那么无论我为spring.jpa.hibernate.ddl-auto选择了哪个option,应用程序都无法创建表。 我的application.properties如下 enter image description here

和pom.xml一样: enter image description here

下面是我们如何工作的图像:从一个表中选择数据并插入另一个表 enter image description here 非常感谢

1 个答案:

答案 0 :(得分:0)

通过使用旧版本的spring boot,我可以解决此问题。以下是pom中的条目:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.7.RELEASE</version>
</parent>
相关问题