注:在整合mybatis的基础上扩展,其他的依赖也在之前springboot内容中
一、引入依赖
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.3.RELEASE</version>
<scope>test</scope>
</dependency>
二、编写测试类
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MySpringbootApplication.class)
public class DemoTest {
@Autowired
private UserServiceImpl userService;
@Test
public void test(){
List<User> userList = userService.findAll();
for (User user : userList) {
System.out.println(user);
}
}
}
三、测试
结束!!!!!
每一次的泪水,都有一次醒悟。