Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [xxx]; nested exception is java.io.FileNotFoundExce

如题, 我在一个普通的java项目中新建了一个bean.xml, 想通过spring的ioc去获取对象 ,谁知道出现这种错误,尝试过几种解决办法:

classpath*:bean.xml

   ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath*:bean.xml");
        UserImpl  userImpl =(UserImpl)applicationContext.getBean("userImpl");

这种方式在applicationContext.getBean("userImpl");会出现Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userImpl' available

根据项目结构目录一级一级的往下找(解决问题)

Exception in thread
QQ截图20180112141429.png
  ApplicationContext applicationContext = new ClassPathXmlApplicationContext("cn/paul/bean.xml");
        UserImpl  userImpl =(UserImpl)applicationContext.getBean("userImpl");
        String name= userImpl.getName("paul");
        System.out.println(name);

你可能感兴趣的:(Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [xxx]; nested exception is java.io.FileNotFoundExce)