Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 春天的世界你好_Java_Eclipse_Spring - Fatal编程技术网

Java 春天的世界你好

Java 春天的世界你好,java,eclipse,spring,Java,Eclipse,Spring,我试图用eclipse上的spring创建一个hello world。但我得到了下一个错误: INFO: Loading XML bean definitions from class path resource [src/com/spr/main/contextApplication.xml] Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOExcept

我试图用eclipse上的spring创建一个hello world。但我得到了下一个错误:

INFO: Loading XML bean definitions from class path resource  
[src/com/spr/main/contextApplication.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [src/com/spr/main/contextApplication.xml]; nested exception is java.io.FileNotFoundException: class path resource [src/com/spr/main/contextApplication.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at com.spr.main.Main.main(Main.java:15)
Caused by: java.io.FileNotFoundException: class path resource [src/com/spr/main/contextApplication.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 4 more


而contextApplication.xml路径是src/com/spr/main/

将您的声明从

XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("\\src\\com\\spr\\main\\contextApplication.xml"));


别忘了检查文件名。

什么代码会出现错误?祝贺你被接受。他的意思是“接受这个答案”——在StackOverflow中,习惯上会将满足你问题的答案标记为“接受”。这样做会提升花时间回答问题的人的声誉,如果你不经常这样做,人们就会停止回答你的问题。
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("\\src\\com\\spr\\main\\contextApplication.xml"));
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("\\src\\com\\spr\\main\\contextApplication.xml"));
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("com\\spr\\main\\contextApplication.xml"));