访问bean时出错

时间:2016-11-24 09:23:11

标签: java spring spring-bean

我在beans.xml中定义了一个bean:

 <bean id="ABCManagerImpl"
      class="com.xyz.manager.impl.ABCManagerImpl" scope="singleton">
       <property name="abcDAO" ref="ABCDAO" />
       <property name="accountManager" ref="AccountManager"/>     
</bean>

在以下JAVA文件中,我正在访问此bean,如下所示:

  public class BankFactory implements ApplicationContextAware{

      private ApplicationContext applicationContext;

      @Override
      public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
          this.applicationContext = applicationContext;
      }
      public ABCManager getManager(String bankName){
           ABCManager abcManager = null;
           abcManager =      
               applicationContext.getBean(ABCManagerImpl.class);
     }
}

但是在上面的行applicationContext.getBean(ABCManagerImpl.class)中,我收到以下错误:

 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.xyz.manager.impl.ABCManagerImpl] is defined. 

0 个答案:

没有答案