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)即可解决该问题。

2019-02-14 Field xxx in xxx required a bean of type 'xxx' that could not be found._第1张图片

你可能感兴趣的:(2019-02-14 Field xxx in xxx required a bean of type 'xxx' that could not be found.)