【发布时间】:2017-11-18 15:24:24
【问题描述】:
在一些单元测试中,我们最初将此类资源链接用于java.net.URL 类
"https://<host name>/<project name>/pom.xml"
用于加载测试数据。但是在离线开发的时候就不行了。
如何从文件系统中的test/java 文件夹 URL 中指定相对 URL?
我试过"file:///../pom.xml",但它带来了异常
java.io.FileNotFoundException: \..\pom.xml (The system cannot find the file specified)
如果我指定"file://..\\pom.xml" 我会收到
Caused by: java.net.UnknownHostException: ..
【问题讨论】:
-
试试
file:../pom.xml。 -
阅读stackoverflow.com/questions/6098472/…>。我想这就是你要找的。span>