Description This exception is thrown when the bean depends on other bean components or some simple properties that were not specified in the definition of the bean factory, although dependency checking has been enabled.
Just look at the classes below for a detailed explanation.
@Controller public class DemoController{ @Autowired private BusinessService service;
Problem: in the DemoController class, we implement the BusinessService class as a dependency, and since the Spring container did not find a component of type BusinessService, therefore the Spring container cannot create an instance of this class, and we get an exception
The reason for the exception: if you look closely at the BusinessService class, we make one mistake, that is, we do not annotate the class using @Service, and the Spring container is not able to create this component, so we get this exception
Solution: Just annotate the BusinessService class with @Service and the code works fine.
//annotating the class with @Service @Service public class BusinessService { //some methods }
Whenever this exception occurs, simply define the role of this particular class and mark the class with the appropriate role, for example:
if your class is designed to annotate data access, then this class is with @Repository
if your class is for Buisness, then annotate this class with @Service
if your class is for Controller, then annotate this class with @Controller
if your class is for sharing, then annotate this class with @Component
For more information click on this: https://www.quora.com/How-can-I-do-to-automatics-reset-auto-increment-values-in-MySQL-table/answer/Shadab-Kazi- 17
source share