使用SpringBoot整合MyBatis时,往数据库里插入中文数据报错
org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'user_name' at row 1
### The error may exist in org/lanqiao/mapper/StudentMapper.java (best guess)
### The error may involve org.lanqiao.mapper.StudentMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO tb_student ( user_name, age ) VALUES ( ?, ? )
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'user_name' at row 1
; Data truncation: Data too long for column 'user_name' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'user_name' at row 1
![在这里插入图片描述](https://img-blog.csdnimg.cn/0aa4ba54477d4a2e902e4eaa55f42d0f.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBARERpb3Jz,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
将其改为UTF-8就好了