成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

java - spring操作數(shù)據(jù)庫顯示中文亂碼的問題?

瀏覽:116日期:2023-08-22 11:06:27

問題描述

操作系統(tǒng):ubuntuIDE:idea數(shù)據(jù)庫:Mysql我用php操作數(shù)據(jù)庫的時候中文顯示是沒有問題的,可以正常顯示中文:java - spring操作數(shù)據(jù)庫顯示中文亂碼的問題?

但是我學(xué)習(xí)spring的時候操作數(shù)據(jù)庫的時候中文就會出現(xiàn)問號,無法正常顯示java - spring操作數(shù)據(jù)庫顯示中文亂碼的問題?

我在spring中寫的數(shù)據(jù)庫配置

# 在項目初始化時,重新創(chuàng)建數(shù)據(jù)表spring.jpa.hibernate.ddl-auto=update# 指定連接的類型為mysql 連接的地址為:localhost 端口為3306 ,數(shù)據(jù)為springmvcspring.datasource.url=jdbc:mysql://localhost:3306/springmvc# 用戶名為rootspring.datasource.username=root# 密碼為空spring.datasource.password=# 顯示SQL語句spring.jpa.show-sql=true

我的數(shù)據(jù)庫和idea都是用的utf_8編碼,為什么會出現(xiàn)這種問題呢?

問題解答

回答1:

修改

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

spring.datasource.url=jdbc:mysql://localhost:3306/springmvc?useUnicode=true&characterEncoding=utf-8

標(biāo)簽: java
相關(guān)文章: