java - spring操作資料庫顯示中文亂碼的問題?
我想大声告诉你
我想大声告诉你 2017-05-16 13:29:37
0
1
407

作業系統:ubuntu
IDE:idea
資料庫:Mysql
我用php作業資料庫的時候中文顯示是沒有問題的,可以正常顯示中文:

但是我學習spring的時候操作資料庫的時候中文就會出現問號,無法正常顯示

#我在spring中寫的資料庫配置

# 在项目初始化时,重新创建数据表
spring.jpa.hibernate.ddl-auto=update
# 指定连接的类型为mysql 连接的地址为:localhost 端口为3306 ,数据为springmvc
spring.datasource.url=jdbc:mysql://localhost:3306/springmvc
# 用户名为root
spring.datasource.username=root
# 密码为空
spring.datasource.password=
# 显示SQL语句
spring.jpa.show-sql=true

我的資料庫和idea都是用的utf_8編碼,為什麼會出現這種問題呢?

我想大声告诉你
我想大声告诉你

全部回覆(1)
習慣沉默

修改

spring.datasource.url=jdbc:mysql://localhost:3306/springmvc

spring.datasource.url=jdbc:mysql://localhost:3306/springmvc?useUnicode=true&characterEncoding=utf-8
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!