SpringBoot Test类注入失败

在这里插入图片描述

本来 bookService的引用一直是null。

导致每次测试都报空指针异常。

然后现在继承相应的 ApplicationTests类,然后使用@Component将该类注册为组件。就可以正常注入了。

猜你喜欢

转载自blog.csdn.net/qq_33247435/article/details/99238056