您好,登錄后才能下訂單哦!
手上有個項目需要以jar方式運行,使用maven-shade-plugin插件構建成功后,在服務器上運行"nohup java -jar myProject.jar > /dev/null &"出錯,錯誤信息:“Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes”,網上搜索了半天,發現一個解決辦法:? http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
在pom文件maven-shade-plugin插件的配置信息中添加:
<configuration>
? ? <filters>
? ? ? ? <filter>
? ? ? ? ? ? <artifact>*:*</artifact>
? ? ? ? ? ? <excludes>
? ? ? ? ? ? ? ? <exclude>META-INF/*.SF</exclude>
? ? ? ? ? ? ? ? <exclude>META-INF/*.DSA</exclude>
? ? ? ? ? ? ? ? <exclude>META-INF/*.RSA</exclude>
? ? ? ? ? ? </excludes>
? ? ? ? </filter>
? ? </filters>
? ? <!-- Additional configuration. -->
</configuration>
繼續運行,之前的錯誤解決了,卻提示新的錯誤:“Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] Offending resource: class path resource [applicationContext.xml]”
解決辦法是在構建的時候加入META-INF/spring.schemas 和 META-INF/spring.handlers transformers,最終的maven-shade-plugin插件信息配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version> 1.7.1</version>
<executions>
<execution>?
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
? ? ? ? <filter>
? ? ? ? ? ? <artifact>*:*</artifact>
? ? ? ? ? ? <excludes>
? ? ? ? ? ? ? ? <exclude>META-INF/*.SF</exclude>
? ? ? ? ? ? ? ? <exclude>META-INF/*.DSA</exclude>
? ? ? ? ? ? ? ? <exclude>META-INF/*.RSA</exclude>
? ? ? ? ? ? </excludes>
? ? ? ? </filter>
? ? </filters>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.zhilin.paopao.server.NIOServer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
重新clean install打包,再次運行之后問題解決~
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。