Incorrect string value: '\xF0\x9F\x91\x80' for column数据库中添加表情报错

错误信息:

Incorrect string value: '\xF0\x9F\x91\x80' for column

解决方法:

  1. 修改数据库中相关字段的字符集为utf8mb4;
  2. 或者修改application.yml
spring:
 datasource:
   url: jdbc:mysql://XXX:3306/XXX?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
   username: root
   password: root #
   tomcat:
     init-s-q-l: SET NAMES utf8mb4     //加上这一块

你可能感兴趣的:(springboot,java,mysql)