首页 > 代码库 > spring boot设定mysql

spring boot设定mysql

mysql创建表,制定自增,utf-8编码

create table person
(id int auto_increment primary key,
 name varchar(100), age int, address varchar(100))
 default charset utf8;
 
 
 mysql依赖
 
 <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
 </dependency>
 
 application.properties
 mysql乱码解决,制定连接子串utf-8
 
spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=user
spring.datasource.password=password

spring boot设定mysql