- 引入MySQL依赖和JPA依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!--<version>5.1.42</version>-->
</dependency>
<!--操作数据库-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
- 配置application.yml文件,注意驱动类和url和以往的不同(添加时区)。注意要设置字符格式,不然中文可能会出现问好情况
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
url: jdbc:mysql://127.0.0.1:3306/数据库名?serverTimezone=UTC&useSSL=false&characterEncoding=UTF-8
password: 123456
jpa:
show-sql: true
database: mysql