SpringBoot做单元测试时报NullPointException 原因:无法加载spring boot启动类 ,junit4需要添加以下代码,junit5则不需要 添加: @SpringBootTest @RunWith(SpringRunner.class) 在Junit4中必须要加入@RunWith注解才可以注入bean、service等,但是junit5则不需要