1. SpringBoot整合JUnit
1.1 添加整合junit起步依赖(可以直接勾选)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
1.2 编写测试类,默认自动生成了一个
@SpringBootTest
class SpringbootJunitApplicationTests {
@Autowired
private BookService bookService;
@Test
public void testSave() {
bookService.save();
}
}
2. SpringBoot整合MyBatis
2.1 创建新模块,选择Spring初始化,并配置模块相关基础信息
2.2 选择当前模块需要使用的技术集(MyBatis、MySQL)
2.3 通过这样的方式创建springboot项目,生成的大概pom文件坐标为
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.9.RELEASE</version>
</parent>
<groupId>com.example</groupId>
<artifactId>springboot-demo5</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>