SpringBoot–application.properties基础连接数据库Navicat配置,可解决中文乱码,Java Persistence Api
可解决中文乱码
Java Persistence Api
内容如下:
#datasource–指定MySQL数据库连接信息
spring.datasource.url = jdbc:mysql://localhost:3306/spring?useUnicode=true&characterEncoding=utf-8
spring.datasource.username = root
spring.datasource.password = root
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.max-active=20
spring.datasource.max-idle=8
spring.datasource.min-idle=8
spring.datasource.initial-size=10
######################################
Java Persistence Api --Spring jpa–Spring Jpa配置信息
######################################
#Specify the DBMS
spring.jpa.database = MYSQL
#show or not log for each sql query–是否显示SQL语句
spring.jpa.show-sql = true
#Hibernate ddl auto (create,create-drop,update)
spring.jpa.properties.hibernate.hbm2ddl.auto=update
#Naming stratety
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
#stripped before adding them to the entity manager
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
#解决中文乱码
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8`