社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  DATABASE

spring data jpa+mysql不支持utf-8

Gearon • 4 年前 • 952 次点击  

在mysql表中插入像汉字这样的unicode字符我很费劲。
堆栈是spring data jpa和mysql。

我尝试过的方法:
1,通过修改application.properties将spring.datasource.url设置为支持utf-8

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=UTF-8
spring.datasource.tomcat.connection-properties=useUnicode=true;characterEncoding=utf-8
connection.useUnicode=true
connection.characterEncoding=utf-8
hibernate.connection.useUnicode=true
hibernate.connection.characterEncoding=UTF-8
spring.datasource.sqlScriptEncoding=UTF-8
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.jpa.show-sql = true

2、设置ide eclipse使用utf-8作为编码方法。
enter image description here

3、mysql通过my.ini设置变量和当前mysql字符集变量如下:
enter image description here

但是,当我试图通过 mysql 命令行工具,表的内容只是乱七八糟的一个问号序列。 我错过了什么吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43421
 
952 次点击  
文章 [ 1 ]  |  最新文章 4 年前