异常信息如下:
nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'xxx' at row
此原因是字段的最大容量小于实际数据的容量导致,但我字段选取的是text,本以为可不限长度,谁知都是假象。原来text类型也是有长度的。
TINYTEXT 256 bytes
TEXT 65,535 bytes ~64kb
MEDIUMTEXT 16,777,215 bytes ~16MB
LONGTEXT 4,294,967,295 bytes ~4GB
这大概是文本类型大概的容量。按照实际情况选取即可。