@SpringBootTest(classes = BYSpringBootApplication.class)
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
public class LearnTest {
@Autowired
private UserService userService;
@Test
public void MyTest(){
User user = userService.findById(1);
System.out.println(user.getUserName());
}
}
@SpringBootTest 写上SpringBoot启动类就可以实现了