解决Field historyService in com.example.fqsystem.demos.Controller.HistoryController required a bean of

报错原因:

这个错误提示意味着在 HistoryController 类中需要一个类型为 HistoryService 的 bean,是找不到该类型的 bean。

原因如下:

  1. 没有在配置文件或者使用注解的方式中声明 HistoryService 类的 bean。你需要确保在应用程序的配置文件(如 application.propertiesapplication.yml)中声明了该 bean,或者使用注解(如 @Service)标记 HistoryService 类。

  2. HistoryService 类所在的包没有被正确扫描。Spring Boot 默认会扫描主应用程序所在的包以及子包中的 bean,你需要确保 HistoryService 类所在的包被正确扫描。

  3. 如果 HistoryService 类是通过依赖注入方式使用的,你需要确保依赖注入的位置正确。如果是在 HistoryController 类中使用 @Autowired 注解注入 HistoryService 类,请确保该注解被正确使用。

猜你喜欢

转载自blog.csdn.net/weixin_64443786/article/details/132369509