Maven 找不到此文件的ab cd配置文件路径:config.properties&书信电报;阶段>;包装</阶段>&书信电报;目标>&书信电报;目标>;阴影</目标></目标>;
mvn包-无法找到jar文件无法找到此属性文件。在Eclipse中,我的应用程序运行良好,但在我创建mvn包之后。runnable jar文件给了我空指针。我使用7zip查看创建可运行jar文件,我看到config.properties被正确添加到jar中,但我的ruunable应用程序jar没有接收它 我在这里得到空指针。。。。。它来自我无法编辑的JAR文件Maven 找不到此文件的ab cd配置文件路径:config.properties&书信电报;阶段>;包装</阶段>&书信电报;目标>&书信电报;目标>;阴影</目标></目标>;,maven,jar,package,runnable,Maven,Jar,Package,Runnable,mvn包-无法找到jar文件无法找到此属性文件。在Eclipse中,我的应用程序运行良好,但在我创建mvn包之后。runnable jar文件给了我空指针。我使用7zip查看创建可运行jar文件,我看到config.properties被正确添加到jar中,但我的ruunable应用程序jar没有接收它 我在这里得到空指针。。。。。它来自我无法编辑的JAR文件 ClassLoader classLoader = super.getClass().getClassLoader();
ClassLoader classLoader = super.getClass().getClassLoader();
File file = new File(classLoader.getResource(fileName).getFile());
if (file.exists()) {
reader = new FileReader(file);
instance.properties.load(reader);
} else {
System.out
.println("Couldnt find ab-cd config file for this filepath:"
+ fileName);
找不到此文件的ab cd配置文件路径:config.properties 10月18日,2015年3:47:24 PM org.springframework.ws.soap.saaj.SaajSoapMessageFactory AfterProperties设置信息:使用soap 1.1协议java.lang.NullPointerException在java.net.URI$Parser.parse创建saaj 1.3 MessageFactory(URI.java:3004)位于java.net.URI。(URI.java:577)位于java.net.URI.create(URI.java:839)位于org.springframework.ws.client.core.WebServiceTemplate$1.getDestination(WebServiceTemplate.java:213)位于org.springframework.ws.client.core.WebServiceTemplate.getDefaultUri(WebServiceTemplate.java:188),位于org.springframework.ws.client.core.WebServiceTemplate.marshallSendAndReceive(WebServiceTemplate.java:380)位于org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:372)
我的pom.xml文件来构建它
<build>
<finalName>AE</finalName>
<plugins>
<!-- download source code in Eclipse, best practice -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.abcdedf.ghi.main.Start</mainClass>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
AE
org.apache.maven.plugins
maven eclipse插件
2.9
真的
假的
org.apache.maven.plugins
maven编译器插件
2.3.2
${jdk.version}
${jdk.version}
org.apache.maven.plugins
maven阴影插件
2.3
包裹
阴凉处
com.abcdedf.ghi.main.Start
.
我不确定我必须将config.properties文件放在哪里,以便我的可运行jar可以选择它。请帮助!在jar文件中,
config.properties
驻留在哪里?在根目录中?我想你不能将类路径中的资源视为文件-因为大部分都驻留在jar中。因此我会尝试从他输入流,而不是将其包装到一个文件:properties.load(classloader.getResourceAsStream(“”)您可能需要先将资源从类路径复制到该文件中。但是,对于flyway配置,也有类路径:因此,运行flyway命令可能不需要所有这些。我解决了它。实际上,我需要将config.properties与生成的*.jar放在一起。不过,感谢您的回复!!