导致构建失败的传递依赖

Transitive dependency causing build failure

我正在创建一个 jar,其中也将包括它的依赖项。我正在为此使用 maven shade 插件。但是在构建时出现 Caused by: java.util.zip.ZipException: invalid LOC header 错误。我尝试排除传递依赖,如下所示仍然出现错误。

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tlt.idk</groupId>
<artifactId>saba-user-import</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>CSVSabaUserImport</name>
<dependencies>
    <dependency>
        <groupId>com.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>3.3</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons.lang3</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
     <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.1</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
         <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <mainClass>ImportCsv</mainClass>
            </transformer>
          </transformers>
        </configuration>
      </execution>
    </executions>
  </plugin>
    </plugins>
</build>

Caused by: java.io.IOException: Problem shading JAR C:\Users\Admin.m2\repository\org\apache\commons\commons-lang3.3.2\commons-lang3-3.3.2.jar entry META-INF/LICENSE.txt: java.util.zip.ZipException: invalid LOC header (bad signature) at org.apache.maven.plugins.shade.DefaultShader.shadeJars(DefaultShader.java:197) at org.apache.maven.plugins.shade.DefaultShader.shade(DefaultShader.java:106) at org.apache.maven.plugins.shade.mojo.ShadeMojo.execute(ShadeMojo.java:442) ... 21 more Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)

在这方面的任何帮助将不胜感激。

我猜是下载依赖项出错了。当 eclipse 为我下载依赖项时,这种情况经常发生。

从您的 Maven 缓存中删除损坏的工件(位于 C:\Users\<username>\.m2\respository)。