mvn package - ruunable jar文件无法找到此属性文件。在Eclipse中我的应用程序运行正常,但在我创建mvn包之后。 runnable jar文件给我空指针。我使用7zip查看create runnable jar文件,我看到config.properties在jar中正确添加,但是我的ruunable应用程序jar没有把它拿起来。
我在这里得到空指针.....它来自我无法编辑的JAR文件。
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 2015年10月18日下午3:47:24 org.springframework.ws.soap.saaj.SaajSoapMessageFactory afterPropertiesSet INFO:使用SOAP 1.1协议java创建SAAJ 1.3 MessageFactory java.net.URI上的java.net.URI $ Parser.parse(URI.java:3004)中的.lang.NullPointerException。(URI.java:577)java.net.URI.create(URI.java:839) org.springframework.ws.client.core.WebServiceTemplate $ 1.getDestination(WebServiceTemplate.java:213)位于org.springframework.ws的org.springframework.ws.client.core.WebServiceTemplate.getDefaultUri(WebServiceTemplate.java:188)。 client.core位于org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:372)的.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:380)
我的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>