class path resource [bean1.xml] cannot be opened because it does not exist
错误重现
bug:Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [bean1.xml]; nested exception is java.io.FileNotFoundException: class path resource [bean1.xml] cannot be opened because it does not exist
public static void main(String[] args) {
//解析beans.xml文件 , 生成管理相应的Bean对象
ApplicationContext context = new ClassPathXmlApplicationContext("bean1.xml");
//getBean : 参数即为spring配置文件中bean的id .
Hello hello = (Hello) context.getBean("hello");
System.out.println(hello.toString());
}
错误原因
简单,就是明明xml在,但是找不到。
解决方法
这样即可!
成功啦!
标签:xml,because,resource,exist,path,class From: https://www.cnblogs.com/Lovi/p/17717574.html