手上有个项目需要以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打包,再次运行之后问题解决~
当前名称:Maven构建可运行的jar包出错解决办法
链接分享:https://www.cdcxhl.com/article38/ihsipp.html
成都网站建设公司_创新互联,为您提供ChatGPT、建站公司、服务器托管、营销型网站建设、全网营销推广、自适应网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联