【发布时间】:2017-07-14 15:35:03
【问题描述】:
这是对How to Configure Eclipse to Work with `ehcache` 的跟进,How to reference a local XML Schema file correctly? 中有一个绝对路径示例
由于不再托管xsd 文件,我从存档下载了一份副本。我已将该文件放在我的资源目录中,并希望在我的 xsi:schemaLocation 中从我的项目的相对路径中引用它。我们有 windows 和 mac 开发人员,所以像 file:///c:/project/foo 这样的绝对路径约定是行不通的。
相对路径的另一种替代方法是,如果有一种方法可以同时引用 windows 和 mac 的系统属性,那么我可以执行 2 个条目,例如 file:///$HOME/workspace/foo。
我的 Mac 上的项目存在于 ~/workspace/foo 中,$HOME 的回声给出了我的主路径。
我的spring-cache.xml 存在于./src/main/webapp/WEB-INF/spring/
我的ehcache-spring-1.2.xsd 存在于./src/main/resources/
以下是我尝试过但没有成功的一些:
file:///$HOME/workspace/foo/src/main/resources/ehcache-spring-1.2.xsd
file:///./src/main/resources/ehcache-spring-1.2.xsd
file:///../../../../resources/ehcache-spring-1.2.xsd
file:///../../../../resources/ehcache-spring-1.2.xsd
../../../../resources/ehcache-spring-1.2.xsd
file://../../../../resources/ehcache-spring-1.2.xsd
file://$HOME/workspace/foo/src/main/resources/ehcache-spring-1.2.xsd
file://./src/main/resources/ehcache-spring-1.2.xsd
file://../../../../resources/ehcache-spring-1.2.xsd
我似乎也有问题让它从绝对路径引用文件,所以也许有不同的方式来引用 mac 上的文件?例如以下方法无效:
file:///Users/me/workspace/foo/src/main/resources/ehcache-spring-1.2.xsd
file:////Users/me/workspace/foo/src/main/resources/ehcache-spring-1.2.xsd
file://Users/me/workspace/foo/src/main/resources/ehcache-spring-1.2.xsd
【问题讨论】: