Sunday, 4 September 2016

Context initialization failed

Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private edu.scramjet.service.AppUserService edu.scramjet.controller.UserController.appUserService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [edu.scramjet.service.AppUserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Solution :
If you look at stack. Spring container is unable to create bean. for userController. unable to autowire the appUserService.

ex :  public class void UserController {
private AppUserService appUserService;     ///  interface object

public User createAppUser(@RequestBody User user ){


return user;


If AppUserService  is object  interface and its autowired. We need to provide Implementation class for bean creation.

public interface AppUserService {

public void createUser();

public interface AppUserService implements  AppUserServiceImpl {

public void createUser() {



No comments:

Post a Comment