(1)maven依赖
(2)编写测试类
@RunWith(SpringRunner.class)
@SpringBootTest(classes=Boot.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class UserServiceTest {
@Autowired
private IUserService userService;
@Test
public void findUsers() {
List users = userService.findUsers();
Assert.assertNotNull(users);
Assert.assertTrue(users.size()>0);
}
}
(3)@SpringBootApplication启动类
@SpringBootApplication
@EnableTransactionManagement
public class Boot {
public static void main(String[] args) {
SpringApplication.run(Boot.class, args);
}
}