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在,但是找不到。
解决方法
这样即可!
成功啦!
- resource because cannot opened classresource because cannot opened filenotfoundexception resource because cannot xxx resource cannot class quot hashcode because cannot verification because cannot failed spring-mvc because spring cannot resource resolve cannot symbol update resources intellij classes directory resource时候cannot class java localdatetime cannot