Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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 XML不存在时,它不存在_Java_Spring_Intellij Idea - Fatal编程技术网

Java XML不存在时,它不存在

Java XML不存在时,它不存在,java,spring,intellij-idea,Java,Spring,Intellij Idea,我对Intellij的想法还不熟悉,并尝试学习一些教程。我试图将XML加载到新的ClassPathXmlApplicationContext()“中。但是,有一个错误指出FileNotFoundException Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path re

我对Intellij的想法还不熟悉,并尝试学习一些教程。我试图将XML加载到
新的ClassPathXmlApplicationContext()“
中。但是,有一个错误指出
FileNotFoundException

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: 
IOException parsing XML document from class path resource [vehicle_beans.xml]; nested exception is java.io.FileNotFoundException: 
class path resource [vehicle_beans.xml] cannot be opened because it does not exist
这是我的结构:

这是我的密码:


这里的XML文件位置是个问题。在项目中使用Maven时,在java级别创建另一个名为“resources”的文件夹,并将XML文件放入其中

src/main/resources


Resources文件夹应包含所有与配置相关的文件,以便应用程序可以使用这些文件。否则,您必须将完整的文件路径传递给文件读取器

请尝试此FileSystemXmlApplicationContext而不是ClassPathXmlApplicationContext

专用静态最终应用程序上下文ac= 新文件系统XmlApplicationContext( “src/main/java/org/example/vehicle\u beans.xml” );

希望它对您有用

以供将来参考。