Reason for error:
This error message means that HistoryController
a HistoryService
bean of type is required in the class, but no bean of this type can be found.
The reasons are as follows:
-
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 (egapplication.properties
or ), or mark the class with an annotation (eg ) .application.yml
@Service
HistoryService
-
HistoryService
The 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 thatHistoryService
the package where the class is located is scanned correctly. -
If
HistoryService
the class is used through dependency injection, you need to make sure that the dependency injection is in the correct location. If you areHistoryController
using@Autowired
the annotation to injectHistoryService
the class in the class, please make sure that the annotation is used correctly.