当前位置: 首页 > 知识库问答 >
问题:

部署Maven项目抛出java.util.zip.ZipException:无效的锁定头(错误签名)

李甫
2023-03-14

运行mvn install时出现以下异常。我甚至删除了本地存储库,并再次运行,得到相同的异常。

[错误]无法执行目标org.apache.maven.plugins:maven-shade-plugin:2.1:在项目核心上的shade(默认)-batch:创建带阴影的JAR时出错:无效的锁头(错误签名)->[帮助1]

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-shade-plugin</artifactId>
   <version>2.1</version>
   <configuration>
      <skipTests>true</skipTests>
   </configuration>
   <executions>
      <execution>
         <phase>package</phase>
         <goals>
            <goal>shade</goal>
         </goals>
         <configuration>
            <artifactSet>
               <excludes>
                  <exclude>commons-logging:commons-logging:jar:*</exclude>
               </excludes>
            </artifactSet>
            <filters>
               <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                     <!-- workaround for a spring issues -->
                     <exclude>META-INF/*.SF</exclude>
                     <exclude>META-INF/*.DSA</exclude>
                     <exclude>META-INF/*.RSA</exclude>
                     <!-- don't want to pick up any other log4j.xml -->
                     <exclude>log4j.xml</exclude>
                  </excludes>
               </filter>
            </filters>
            <!-- May be needed to work around another issue in Spring -->
            <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>
            </transformers>
         </configuration>
      </execution>
   </executions>
</plugin>

错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project cores-batch: Error creating shaded jar: invalid LOC header (bad signature) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project cores-batch: Error creating shaded jar: invalid LOC header (bad signature)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating shaded jar: invalid LOC header (bad signature)
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:528)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$1400(ZipFile.java:56)
    at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:679)
    at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:415)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.codehaus.plexus.util.IOUtil.copy(IOUtil.java:189)
    at org.codehaus.plexus.util.IOUtil.copy(IOUtil.java:175)
    at org.apache.maven.plugins.shade.DefaultShader.addResource(DefaultShader.java:427)
    at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:186)
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:458)
    ... 21 more
[ERROR] 
[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

共有1个答案

楚威
2023-03-14

您需要检查哪个罐子出了问题。一定是被腐蚀了。删除该jar并再次运行mvn spring-boot:run命令。可能有多个jar已损坏,因此每次需要运行该命令来删除该jar。在我的例子mysql,jackson中,方面jars被破坏了mvn spring-boot:run命令3次,我发现了这一点,并从.m2文件夹中删除了jars。现在问题已经解决了。

 类似资料:
  • 问题内容: 在执行这段(相对简单的)代码时,我得到了这个错误: 其实。有趣的是,我在java-sun-6u32和java-1.6.0-openjdk-amd64上得到它,但是java- sun-7u4成功了。解压缩本身似乎可以解决问题。我猜这意味着这些zipfile可能是由Java 7可以理解的某些较新版本的zip创建的,而以前的版本则不是。但是,任何见识将不胜感激。另外,由于在生产中我真的没有使

  • 我有这个错误,我试图解决它,但我不能。 组织。素面。扩展。组成部分格哈特。GChartRenderer'缺少一个运行时依赖项:java。lang.NoClassDefFoundError:com/google/gson/GsonBuilder 错误[org.jboss.msc.service.fail](ServerService线程池--64)MSC000001:无法开启服务jboss.unde

  • 我在Maven构建期间收到此错误。 无法执行目标组织。阿帕奇。专家插件:maven shade插件:2.4.3:项目dl4j上的shade(默认)示例:创建着色jar时出错:无效的LOC头(错误签名)- 这是我的pom。xml文件。 我多次尝试删除jar文件,但似乎都不起作用。

  • 最近,我一直试图在CentOS服务器上使用< code>mod_wsgi部署django站点,但到目前为止,当我试图通过我的笔记本电脑访问Django站点时,网页只显示< code >错误:403禁止您没有权限在此服务器上访问/ 除了阅读所有显而易见的文档之外,我还研究了前面的这些问题: Django mod_wsgi Apache = 403 禁止 错误消息“禁止您无权访问 / 在此服务器上”

  • 这是我在POM中的构建详细信息: 这些是我的财产: 以下是我的终端命令: MVN清洁部署-DmuleDeploy-X,我得到以下错误: 如果我使用以下配置,它将成功部署在Cloud dhub中: 不确定我在第一个配置中做错了什么。