有时我会在其他人的代码中看到这一点。但是当我尝试时,它返回 null。
baseUrl = org.company.UploadService.class.getResource(".");
url = new URL(baseUrl, "http://192.168.164.32:9080/mka-web/services/UploadService?wsdl");
最佳答案
getResource(".")
在某些情况下会返回指向类文件所在目录的 URL。
This thread将行为描述为:
a URL pointing to the directory in the class path used to load the class if the class is loaded from a directory, or null when loaded from a jar.
最后一部分可能是您得到 null
的原因。另一个原因可能是:
It does not work with all JVMs
关于java - class.getResource ("."/*dot*/) 有什么特殊含义吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24307480/