search

Home  >  Q&A  >  body text

java - Spring operation database displays garbled Chinese characters?

Operating system: ubuntu
IDE:idea
Database: Mysql
When I use php to operate the database, there is no problem with Chinese display, and Chinese can be displayed normally:

But when I was learning spring and operating the database, question marks would appear in Chinese and could not be displayed normally

The database configuration I wrote in 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

My database and idea are both encoded in utf_8. Why does this problem occur?

我想大声告诉你我想大声告诉你2775 days ago533

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 13:31:37

    Modification

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

    for

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

    reply
    0
  • Cancelreply