You don't have to necessarily provide name and Qualifier. If you set a name, that's the name with which the bean is registered in the context. If you don't provide a name for your service it will be registered as uncapitalized non-qualified class name based on BeanNameGenerator
. So in your case the Implementation will be registered as employeeServiceImpl
. So if you try to autowire with that name, it should resolve directly.
private EmployeeService employeeServiceImpl;
@RequestMapping("/employee")
public String employee() {
this.employeeService.fetchAll();
return "employee";
}
@Autowired(required = true)
public void setEmployeeService(EmployeeService employeeServiceImpl) {
this.employeeServiceImpl = employeeServiceImpl;
}
@Qualifier
is used in case if there are more than one bean exists of same type and you want to autowire different implementation beans for various purposes.