Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无效的LOC标头(错误签名)_Java_Maven_Pom.xml - Fatal编程技术网

Java 无效的LOC标头(错误签名)

Java 无效的LOC标头(错误签名),java,maven,pom.xml,Java,Maven,Pom.xml,我在Maven构建期间遇到了这个错误 无法在项目dl4j上执行goal org.apache.maven.plugins:maven shade plugin:2.4.3:shade(默认值)示例:创建着色jar时出错:无效的LOC头(错误签名)->[帮助1] [错误] 这是我的pom.xml文件 <plugin> <groupId>org.apache.maven.plugins</groupId> &

我在Maven构建期间遇到了这个错误

无法在项目dl4j上执行goal org.apache.maven.plugins:maven shade plugin:2.4.3:shade(默认值)示例:创建着色jar时出错:无效的LOC头(错误签名)->[帮助1] [错误]

这是我的pom.xml文件

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>${maven-shade-plugin.version}</version>
            <configuration>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>${shadedClassifier}</shadedClassifierName>
                <createDependencyReducedPom>true</createDependencyReducedPom>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>org/datanucleus/**</exclude>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>

            </configuration>

            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                <resource>reference.conf</resource>
                            </transformer>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>

org.apache.maven.plugins
maven阴影插件
${maven shade plugin.version}
真的
${shadedClassifier}
真的
*:*
组织/数据核/**
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
包裹
阴凉处
reference.conf

我多次尝试删除jar文件,但似乎都不起作用。

我也遇到了同样的问题,Ben是正确的,这是jar文件损坏的情况。只需转到.m2 repo文件夹并从中删除它,然后再次构建它(mvn clean install)。它会解决这个问题。

我已经面临这个问题很久了

所以我决定自动识别和移除损坏的罐子

这是我为此目的创建的util类:

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.jar.JarFile;

public class MavenFix {

    public static void main(String[] args) throws IOException {
        Files.walk(Paths.get("C:/data/.m2/repository"))
        .filter(file -> file.toString().endsWith("jar"))
        .forEach(path -> {
            try {
                System.out.print(".");
                new JarFile(path.toString(), true).getManifest();
            } catch (Exception e) {
                System.out.println();
                System.out.println(path + " - " + e.getMessage());
                try {
                    cleanAndDeleteDirectory(path.getParent().toFile());
                } catch (IOException e1) {
                    System.err.println(e1.getMessage());
                }
            }
        });
    }

    public static void cleanAndDeleteDirectory(File dir) throws IOException {
        File[] files = dir.listFiles();
        if (files != null && files.length > 0) {
            for (File aFile : files) {
                Files.delete(aFile.toPath());
            }
        }
        Files.delete(dir.toPath());
    }
}

我面临同样的问题,只需将其从.m2文件夹中删除,然后再次构建,您的问题将得到解决

您是否尝试删除(在上次备份之后…)您的
.m2\repository
文件夹?从repo返回的jar已损坏。尝试从其他镜像下载它。这就是为什么即使清理本地repo也无法修复它的原因。
.m2
repo实际上在哪里?@MohammedsalimShivani它通常在
C:\User\
folder下。谢谢你的提示@Darren,但我使用的是带宽有限的VPN,下载所有依赖项需要几个小时,所以这个解决方案更适合我