记一次工作中遇到的bug.警醒自己!
在进行Cucumber测试时,启动测试程序却报错: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
上网查资料找到各种解决方案,但是问题都未得到解决.
最后在找到造成错误的原因:
@SpringBootTest(classes=API.class,webEnvironment=SpringBootTest.WebEnvironment.DEFINED_PORT)
其中我的启动类名为:AppApi,可是在程序中却写成了API 因此程序一直加载不了bean,扫描不到包下的各种资源.故而报错.
最后将上述代码改为:
@SpringBootTest(classes = AppAPI.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
问题解决!
这次与遇到的bug说到底还是自己对技术不够了解,很多东西都是一知半解.写下这次bug经历,希望自己能记住这次教训,