org.springframework.beans.factory.BeanCreationException:创建名为' securityServiceImpl'的bean时出错:

时间:2016-06-02 12:47:09

标签: java spring spring-mvc

请在运行我的应用程序时为什么会出现此错误

SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityServiceImpl': Injection of autowired dependencies failed;
 nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.authentication.AuthenticationManager com.springfoundation.service.SecurityServiceImpl.authenticationManager; 
 nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
  No unique bean of type [org.springframework.security.authentication.AuthenticationManager] is defined:
  expected single matching bean but found 3: 
  [org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,
   org.springframework.security.authentication.ProviderManager#0,
   org.springframework.security.authenticationManager]

    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)

这是第二个堆栈跟踪

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.authentication.AuthenticationManager com.springfoundation.service.SecurityServiceImpl.authenticationManager; 
 nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
  No unique bean of type [org.springframework.security.authentication.AuthenticationManager] is defined:
  expected single matching bean but found 3: 
  [org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0,
   org.springframework.security.authentication.ProviderManager#0,
   org.springframework.security.authenticationManager]

    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:513)

有什么问题?

1 个答案:

答案 0 :(得分:0)

上述异常意味着您可能忘记定义实现DAO接口的bean。

<bean id="object name" class="com.java.model.FirstModelImple" />