作業(yè)系統(tǒng):ubuntu
IDE:idea
資料庫:Mysql
我用php作業(yè)資料庫的時候中文顯示是沒有問題的,可以正常顯示中文:
但是我學(xué)習(xí)spring的時候操作資料庫的時候中文就會出現(xiàn)問號,無法正常顯示
#我在spring中寫的資料庫配置
# 在項目初始化時,重新創(chuàng)建數(shù)據(jù)表
spring.jpa.hibernate.ddl-auto=update
# 指定連接的類型為mysql 連接的地址為:localhost 端口為3306 ,數(shù)據(jù)為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編碼,為什麼會出現(xiàn)這種問題呢?
修改
spring.datasource.url=jdbc:mysql://localhost:3306/springmvc
為
spring.datasource.url=jdbc:mysql://localhost:3306/springmvc?useUnicode=true&characterEncoding=utf-8