Java 加载应用程序上下文文件Bean.xml

Java 加载应用程序上下文文件Bean.xml,java,spring,Java,Spring,我想定制一个现有的。我可以毫无错误地构建和部署该项目。我的问题是如果我尝试加载BeanLocation.xml new ClassPathXmlApplicationContext("file:spring/config/BeanLocations.xml"); 它抛出错误: class org.springframework.beans.factory.BeanDefinitionStoreException IOException parsing XML document from UR

我想定制一个现有的。我可以毫无错误地构建和部署该项目。我的问题是如果我尝试加载BeanLocation.xml

 new ClassPathXmlApplicationContext("file:spring/config/BeanLocations.xml");
它抛出错误:

class org.springframework.beans.factory.BeanDefinitionStoreException
IOException parsing XML document from URL [file:resources/spring/config/BeanLocations.xml]; nested exception is java.io.FileNotFoundException: resources/spring/config/BeanLocations.xml (No such file or directory)
如果您仔细查看我的类路径:

 C:/Program Files/Java/jdk1.8.0_60/lib/tools.jar;C:/Users/admin/workspace/ssf/samples/customcontroller/../../as-common/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../as-shared/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../commons-httpclient-contrib/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../gwt/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../indexer-lucene/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../jboss-portal/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../liferay/liferay/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../liferay-light/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../lucene-contrib/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../main/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../main-minimum/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../portal-module/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../remoting/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../rest-shared/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../slide-webdavclient/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../ssfs/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../taglib/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../tools/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../util/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../util-search/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/../../liferay/teaming/classes;C:/Users/admin/workspace/ssf/samples/customcontroller/src/resources

然后您将找到
C:/Users/admin/workspace/ssf/samples/customcontroller/src/resources
,其中包含文件
C:/Users/admin/workspace/ssf/samples/customcontroller/src/resources/spring/config/BeanLocation.xml
您正在使用的是
文件
uri。这种uri不关心类路径,而是读取相对于当前文件夹的文件


使用
classpath
uri,或者用正确的路径设置
文件
uri。

不使用
文件:
我得到了相同的错误。可能重复
类路径*:spring/config/BeanLocations.xml
对我有用,但我想知道如何通过
文件:
加载,或者不使用
文件:
前缀加载。您建议使用什么来代替它“file:spring/config/BeanLocations.xml”我尝试了很多方法,但都没有成功。