我需要获取 jar 文件中资源的 URL。我使用此 URL 作为服务调用的参数。我的下面的代码失败并出现“没有这样的文件或目录”错误。
File file = new File(classLoader.getResource("AXLAPI.wsdl").getFile());
final URL wsdlURL = new URL(this.getClass().getResource(this.getClass().getSimpleName() +".class"),file.toString());
String endpoint = "https://<machine>:8443/axl/";
AXLAPIService ss = new AXLAPIService( wsdlURL );
下面是执行此操作时看到的错误 -
Failed to access the WSDL at: file:/blah/blah/blah.jar!/AXLAPI.wsdl. It failed with:
/blah/blah/blah.jar!/AXLAPI.wsdl (No such file or directory).
我真的很感激任何处理这个问题的建议!
最佳答案
我认为正确的网址应该是
jar:file:/blah/blah/blah.jar!/AXLAPI.wsdl
关于java - JAR 中资源的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11250011/