JDBC 相关配置
1.pom.xml 文件
<!--jdbc 启动器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--mysql 驱动包-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
2.application.yml
(注意:mysql 8.x 版本驱动包,要使用 com.mysql.cj.jdbc.Driver 作为驱动类)
spring:
datasource:
username: root
password: root
#使用 MySQL 连接驱动是 8.0 以上,需要在 Url 后面加上时区, GMT%2B8 代表中国时区,不然报时区错误
url: jdbc:mysql://127.0.0.1:3306/jdbc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=
convertToNull&useSSL=true&serverTimezone=GMT%2B8
# 注意: 新版本驱