SERIALIZED CONTEXT 数据截断问题 [SPRING BATCH]

SERIALIZED CONTEXT data truncation issue [SPRING BATCH]

由于 spring 引导升级到 spring 引导 2.1.6,我在数据库上遇到 spring 批处理异常:

Caused by: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'SERIALIZED_CONTEXT' at row 1
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:955)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1094)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1042)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1345)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1027)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.springframework.jdbc.core.JdbcTemplate.lambda$update[=11=](JdbcTemplate.java:866)
at org.springframework.jdbc.core.

我不会直接在数据库上更改列,我会寻找一个干净的解决方案。有谁知道如何解决此异常?

提前致谢。

I dont won't to change the column directly on database, I look for a clean solution. Does anyone have an idea how to resolve this exception ?

Spring批处理不会阻止你在执行上下文中放置任何你想要的东西,但同时不能强制数据库接受超过列定义接受的内容。

因此,解决此问题的最简单方法是修改 DDL 中的列并在 JobRepositoryFactoryBean#setMaxVarCharLength 中设置适当的值。