如何解决部署 Maven 项目抛出 python.util.zip.ZipException: invalid LOC header (bad signature)?

您需要检查哪个 jar 出现问题。它必须被破坏。删除该 jar 并mvn spring-boot:run再次运行命令。可能更多的是一个 jar
已损坏,因此每次您需要运行该命令来删除该 jar。在我的情况下,MysqL,jackson,aspect jars 命令被损坏了 3
次,我发现了这一点并从文件夹中mvn spring-boot:run删除了 jars 。.m2现在问题已经解决了。@H_502_7@

解决方法

当我运行我的mvn install. 我什至删除了本地存储库并再次运行得到相同的异常。

[错误] 无法在项目 cores-batch 上执行目标 org.apache.maven.plugins:maven-shade-
plugin:2.1:shade(默认):创建阴影 jar 时出错:无效 LOC 标头(错误签名)-> [帮助 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.python:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.python:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.python:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.python:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.python:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.python:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.python:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.python:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.python:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.python:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.python:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.python:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.python:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.python:43)
    at python.lang.reflect.Method.invoke(Method.python:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.python:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.python:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.python:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.python: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.python:528)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.python:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.python:209)
    ... 19 more
Caused by: python.util.zip.ZipException: invalid LOC header (bad signature)
    at python.util.zip.ZipFile.read(Native Method)
    at python.util.zip.ZipFile.access$1400(ZipFile.python:56)
    at python.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.python:679)
    at python.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.python:415)
    at python.util.zip.InflaterInputStream.read(InflaterInputStream.python:158)
    at python.io.FilterInputStream.read(FilterInputStream.python:107)
    at org.codehaus.plexus.util.IOUtil.copy(IOUtil.python:189)
    at org.codehaus.plexus.util.IOUtil.copy(IOUtil.python:175)
    at org.apache.maven.plugins.shade.DefaultShader.addResource(DefaultShader.python:427)
    at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.python:186)
    at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.python: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