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

Reason for error:

This error message means that HistoryControllera HistoryServicebean of type is required in the class, but no bean of this type can be found.

The reasons are as follows:

  1. The bean of the class is not declared in the configuration file or using annotations HistoryService. You need to make sure that the bean is declared in your application's configuration file (eg application.propertiesor ), or mark the class with an annotation (eg ) .application.yml@ServiceHistoryService

  2. HistoryServiceThe package in which the class resides was not scanned properly. By default, Spring Boot will scan the package where the main application is located and beans in sub-packages. You need to ensure that HistoryServicethe package where the class is located is scanned correctly.

  3. If HistoryServicethe class is used through dependency injection, you need to make sure that the dependency injection is in the correct location. If you are HistoryControllerusing @Autowiredthe annotation to inject HistoryServicethe class in the class, please make sure that the annotation is used correctly.

Guess you like

Origin blog.csdn.net/weixin_64443786/article/details/132369509