测试类中加两个注解就行
@SpringBootTest(classes = Application.class)//添加SpringBoot 的启动类,万无一失
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringBootJunitTest {@Testpublic void test(){System.out.println("ddddddddddddddddddd");}}
@SpringBootTest
@ContextConfiguration(classes = Application.class)
上面两个背景黄色的注解,
@SpringBootTest(classes = Application.class)//添加SpringBoot 的启动类,万无一失
一行等同于下面两行,功能一样
@SpringBootTest
@ContextConfiguration(classes = Application.class)