黑马程序员Spring Boot2
文章目录
- 1、步骤
- 1.1 手动添加坐标
- 1.2 配置
- 1.3 定义数据层接口与映射配置,继承BaseMapper
- 1.4 测试
1、步骤
1.1 手动添加坐标
- 手动添加SpringBoot整合MyBatis-Plus 的坐标,可以通过mvnrepository获取
- 创建新的模块,勾选 MySQL Driver
- 访问 https://mvnrepository.com/ 搜索 mybatis plus ,点击第一个,自行选择一个版本,复制其坐标,粘贴到 pom.xml 中,刷新Maven之后爆红消失
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.3</version></dependency>
注意事项:由于SpringBoot中未收录MyBatis-Plus 的坐标版本,需要指定对应的Version
1.2 配置
- 在application.yml 中配置数据库连接相关信息
# 配置相关信息
spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/mytliasusername: rootpassword: 123456