数据库配置指引
SpringBoot+MyBatis + MySQL
application.yaml文件
server:
port: 8080
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${数据库名}?createDatabaseIfNotExist=TRUE&useUnicode=TRUE&characterEncoding=UTF-8&autoReconnect=TRUE&serverTimezone=GMT%2b8
username: ${MYSQL_USER}
password: ${MYSQL_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
数据库名记得更改为实际生成的数据库名
pom.xml文件
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<!-- jdbc -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>