在测试类上添加
@RunWith(SpringRunner.class)
@SpringBootTest(classes=MyApplication.class)
这样就可正常使用@autowired等注解了
其中,使用classes属性指定启动类
在测试类上添加
@RunWith(SpringRunner.class)
@SpringBootTest(classes=MyApplication.class)
这样就可正常使用@autowired等注解了
其中,使用classes属性指定启动类