spring boot设定mysql

来源:互联网 发布:网站建设方案书 阿里云 编辑:程序博客网 时间:2024/06/05 11:38
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


0 0