1. 测试类的包路径和项目扫描路径不一致
2.测试方法返回值必须为void, 并且没有参数
3. @SpringBootTest指定springboot启动类
@SpringBootTest(classes = MyApplication.class)
4. 在junit之前添加系统变量通过static代码块
static {
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
}
@Test
public void test() {
}
5. springboot启动类添加包扫描@ComponentScan(basePackages ={"com.zzy"})