【问题标题】:Loading Application Context File Bean.xml加载应用程序上下文文件 Bean.xml
【发布时间】:2016-07-06 08:40:51
【问题描述】:

我想自定义一个现有的project。我可以毫无错误地构建和部署该项目。我的问题是如果我尝试加载我的 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

【问题讨论】:

标签: java spring


【解决方案1】:

您正在使用 file uri。这种uri不关心classpath,而是读取一个相对于当前文件夹的文件。

使用classpath uri,或使用正确的路径设置file uri。

【讨论】:

  • classpath*:spring/config/BeanLocations.xml 对我有用,但我想知道如何通过 file: 或不使用 file: 前缀加载。
  • 你建议使用什么来代替“file:spring/config/BeanLocations.xml” 我尝试了很多方法,但没有任何效果。
猜你喜欢
  • 1970-01-01
  • 2021-03-01
  • 2015-04-28
  • 2011-05-13
  • 2012-10-04
  • 1970-01-01
  • 2021-07-27
  • 2018-12-25
  • 2023-04-09
相关资源
最近更新 更多