SpringBoot单元测试报空指针异常

错误现象:

java.lang.NullPointerException

解决方案:确保引入以下包 和 添加对应注解

import org.junit.Test;
import org.junit.runner.RunWith;

@SpringBootTest
@RunWith(SpringRunner.class)

错误分析:在使用@Test时引入了错误的包 记得删除其他的Test包引入