為將專案從postgre庫轉為本地mysql資料庫,需要將資料庫驅動改為mysql
1.在父工程的pom中引入資料庫
<!-- Mysql驅動包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
2.在配置檔案中application.yml中寫引入的主資料庫驅動和連線資訊
datasource:
hikari:
auto-commit: false
type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: org.postgresql.Driver
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主庫資料來源
master:
url: jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 'root'
發現引入的驅動名報紅,我的解決方式是