2019-02-14 Field xxx in xxx requ

2019-02-14  本文已影响0人  小白修仙之路

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

上一篇 下一篇

猜你喜欢

热点阅读