解决springboot测试类注入bean为null
- springboot测试类时注入对象为NullPointerException时:
正常来说测试类加@SpringBootTest可以正常@Test测试
但@SpringBootTest(classes = BootApplication.class)中的classes的值要纸箱启动类的才可以正常注入属性。也就是说BootApplication是springboot启动类
@RunWith(SpringRunner.class)
@SpringBootTest(classes = GrouptwoApplication.class)