我在一个通过JPA访问的MySQL数据库上有一个可本地化的/unicode JSON列。在我的API响应中,我得到了乱码字符串
{
"bannerTitle": "Copyright © 2019",
}JSON绑定到以下实体属性
@Column(nullable = false, columnDefinition = "json")
private String settings;我的数据源URL具有如下Unicode标记
jdbc:mysql://localhost:3306/mydb?characterEncoding=utf-8&useUnicode=yes我尝试在以下几行中使用转换器
public class StringToByteConverter implements AttributeConverter<String, byte[]> 它修复了我的fetch查询,但是我的save查询崩溃了
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.在使用JPA持久化库时,正确的修复方法是什么?
操作系统: Ubuntu 18.04
MySQL: 5.7.27
Java: openjdk版本"1.8.0_222“
Spring boot :1.5.6版本
https://stackoverflow.com/questions/57696860
复制相似问题