springboot测试类无法注入bean
生活随笔
收集整理的這篇文章主要介紹了
springboot测试类无法注入bean
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
針對問題:springboot測試類中的@Autowired注解報空指針異常
解決方法:
首先在測試類上加上
然后在測試方法上加上
@Test示例
@RunWith(SpringRunner.class) @SpringBootTest(classes = FiscoBcosServiceApplication.class) public class BlockChainServiceImplPlusTest extends TestCase {@AutowiredBlockChainServiceImpl bcsp;@Testpublic void testRegister() {bcsp.register("13212");} }總結
以上是生活随笔為你收集整理的springboot测试类无法注入bean的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【ArcGIS教程01】前言
- 下一篇: Appium iOS 自动化测试总结