maven-shade-plugin插件打包异常解决方案

异常提示如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.4.3:shade (default) on project spark-workcount: Error creating shaded jar: invalid LOC header (bad signature) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这种情况是打包时相关jar包没下载完整,可以看到关键错误信息是:

invalid LOC header (bad signature)

并且给出了解决方案:

Re-run Maven using the -X switch to enable full debug logging.

意思是重新运行下-X查看完整DEBUG日志信息。
只需要在Terminal窗口执行mvn -X package即可,如下:
在这里插入图片描述
mvn -X package是mvn 命令,其中-X代表DEBUG模式,有兴趣的同学可以深入了解下。
当然,这个Terminal终端相当于cmd黑窗,也可以在黑窗的同样目录下执行这个mvn指令,效果相同。

黑窗操作步骤:win+r -> cmd -> cd /d +(最后一个debug的路径)

在这里插入图片描述
当时没截图,这个是我已经处理好后重新做的图。正常最后一个DEBUG后面跟的就是jar包下载有误的路径,找到那个路径,发现有一个-in-progress文件,说明确实是没有下完。删除全部文档,重新打包下载即可。

猜你喜欢

转载自blog.csdn.net/weixin_43644153/article/details/87803817