Maven构建可运行的jar包出错解决办法
2015-01-28 17:06
330 查看
手上有个项目需要以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插件的配置信息中添加:
继续运行,之前的错误解决了,却提示新的错误:“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插件信息配置如下:
重新clean install打包,再次运行之后问题解决~
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打包,再次运行之后问题解决~
相关文章推荐
- Jenkins构建maven项目时日志报代码缺少jar包错误的解决办法
- eclipse构建maven项目出错解决办法
- ECLIPSE中MAVEN构建spring 多模块工程jar包不能自动扫描问题解决办法
- VS(C#)试图运行项目时出错,无法启动调试,绑定句柄无效解决办法
- VS.NET"试图运行项目时出错:无法启动调试。绑定句柄无效"解决办法
- Ubuntu 7.04安装运行VirtualBox出错的解决办法
- jar文件运行时:Failed to load Main-Class manifest attribute from ......解决办法
- webwork/struts2 直接运行带有 标签页面出错的解决办法
- Ubuntu 7.04安装运行VirtualBox出错的解决办法
- VS2005.NET提示"试图运行项目时出错,无法启动调试,绑定句柄无效"解决办法
- 试图运行项目时出错:无法在web服务器上启动项目得解决办法
- jar文件运行时:Failed to load Main-Class manifest attribute from ......解决办法
- VS.NET提示"试图运行项目时出错:无法启动调试。绑定句柄无效"解决办法
- VS.NET提示"试图运行项目时出错:无法启动调试。绑定句柄无效"解决办法
- “试图运行项目时出错:无法在 web 服务器上启动调试。” 的解决办法
- Ubuntu 7.04安装运行VirtualBox出错的解决办法
- VisualStudio.NET提示试图运行项目时出错:无法启动调试。绑定句柄无效解决办法
- 试图运行项目时出错:无法在web服务器上启动项目得解决办法
- 试图运行项目时出错:无法在web服务器上启动项目得解决办法
- vmware安装运行出错问题及解决办法汇总