我将放在applicationContext.xml与 Java 类相同的目录和包中。
执行以下操作来阅读它:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
Run Code Online (Sandbox Code Playgroud)
然而,我一直遇到:
IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException
我没有得到:文件在那里,与类位于同一目录中。它们甚至被编译成/out,我可以看到它就在那里。
我试过把它放进去,src/resources/applicationContext.xml但无济于事。
Spring 会在类路径的根目录中寻找它......
src/resources 根本不在你的类路径上如果你把它放进去,src/main/resources那么它将在你的类路径中(1)和(2)在你的类路径的根目录中。
| 归档时间: |
|
| 查看次数: |
4635 次 |
| 最近记录: |