Jam*_*vec 5 java xsd ehcache xsi
这是如何配置 Eclipse 以使用 `ehcache` 的后续内容,并且在如何正确引用本地 XML 架构文件?中有一个绝对路径的示例。
由于该xsd文件不再托管,我从存档中下载了它的副本。我已将该文件放入我的资源目录中,并希望xsi:schemaLocation从项目的相对路径中引用它。我们既有 Windows 也有 Mac 开发人员,因此像这样的绝对路径约定file:///c:/project/foo是行不通的。
相对路径的另一种替代方法是,如果有一种方法可以引用 Windows 和 Mac 的系统属性,那么我可以执行 2 个条目,例如file:///$HOME/workspace/foo.
我的 Mac 上的项目存在于~/workspace/foo$HOME 中,并且 $HOME 的 echo 给出了我的主路径。
我的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
Run Code Online (Sandbox Code Playgroud)
我似乎也遇到了让它从绝对路径引用文件的问题,所以也许有不同的方法在 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
Run Code Online (Sandbox Code Playgroud)
我认为我的问题是 webapp 目录可能看不到资源文件夹。
我这样说是因为根据对以下堆栈溢出问题的阅读,看起来相对路径的内容应该非常简单:带有 XML 架构本地副本的 XML 文件以及如何在 XML 文档中使用本地计算机上的架构
然后,我尝试暴力引用引用,以防它是部署目录或类路径的内容,并且以下所有操作都失败了:
../../../../resources/ehcache-spring-1.2.xsd
../../../resources/ehcache-spring-1.2.xsd
../../resources/ehcache-spring-1.2.xsd
../resources/ehcache-spring-1.2.xsd
./resources/ehcache-spring-1.2.xsd
../ehcache-spring-1.2.xsd
./ehcache-spring-1.2.xsd
Run Code Online (Sandbox Code Playgroud)
解决方案:
但是,通过将 xsd 文件从./src/main/resources/移至./src/main/webapp/WEB-INF/spring/,我就可以正确/轻松地引用它ehcache-spring-1.2.xsd
| 归档时间: |
|
| 查看次数: |
7734 次 |
| 最近记录: |