加载jar中包含的资源
在我的应用程序中,我以这种方式加载资源:
WinProcessor.class.getResource("repository").toString();
这给了我:
file:/root/app/repository (and I replace "file:" with empty string)
当我从IDE运行我的应用程序时,这工作正常,但是当我运行我的应用程序的jar时:
java -jar app.jar
路径变成:
jar:/root/app.jar!/repository
有什么方法可以解决这个问题吗?
我将使用“repository”目录名称来创建:
ConfigurationContext ctx = (ConfigurationContext) ConfigurationContextFactory.createConfigurationContextFromFileSystem(repositoryString, null);
以同样的方式,我将获得一个文件名(而不是一个目录),我将以这种方式使用它:
System.setProperty("javax.net.ssl.trustStore", fileNameString)
繁星coding
慕丝7291255
相关分类