1、在 pom.xml 中集成MySQL连接

<!-- 集成MySQL连接 -->
<dependency>
	<groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.25</version>
</dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2、在 application.yml 中配置数据源

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/wiki?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver

更多推荐