1.MySQL数据源配置
在application.yml文件中加入MySQL数据源配置
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: password
2.加入数据库相关依赖包
1.使用MySQL驱动,在pom.xml中加入MySQL的依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
2.使用MyBatis,在pom.xml中加入MyBatis的依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>RELEASE</version>
</dependency>
网友评论