2019-02-14 Field xxx in xxx required a bean of type 'xxx' that could not be found.

使用springboot的测试类进行测试时遇到了错误:

Description:

Field analysisLibMgtService in com.yl.analysismgt.controller.AnalysisLibMgtController required a bean of type 'com.yl.analysismgt.service.AnalysisLibMgtService' that could not be found.

The injection point has the following annotations:

- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'com.yl.analysismgt.service.AnalysisLibMgtService' in your configuration.


错误原因:测试类中写成了@SpringBootTest(classes = AnalysisLibMgtController.class)

AnalysisLibMgtController非启动类,不能扫描到AnalysisLibMgtService。

改成//@SpringBootTest(classes = UapLabService.class)即可解决该问题。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容