新建测试类
编写测试类
1 package com.dszh.demo2; 2 3 import com.dszh.demo2.entity.User; 4 import com.dszh.demo2.mapper.UserMapper; 5 import org.junit.Test; 6 import org.junit.runner.RunWith; 7 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.boot.test.context.SpringBootTest; 9 import org.springframework.test.context.junit4.SpringRunner; 10 11 import java.util.List; 12 13 @RunWith(SpringRunner.class) 14 @SpringBootTest 15 public class UserTest { 16 @Autowired 17 private UserMapper userMapper; 18 19 @Test 20 public void test1(){ 21 System.out.println(("----- selectAll method test ------")); 22 List<User> userList = userMapper.selectList(null); 23 for (User tempUser:userList ) { 24 System.out.println(tempUser); 25 } 26 } 27 }
运行测试类,返回从数据库查询到的数据集
到这里,基本的springboot + mybatis-plus +mysql 后台服务应用就完成了。
原文地址:https://www.cnblogs.com/superisland/p/11022436.html
时间: 2024-11-07 05:19:22