Maven - 无法找到有效的证书路径

时间:2018-02-03 01:52:36

标签: maven dependencies

我是maven的新手,在添加依赖项时遇到问题(sl4j)。我得到了这个项目,显然是从蚂蚁转变为maven。顺便说一句,干净的安装不起作用。这是pom.xml:

<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.xxx.tools</groupId>
    <artifactId>someName</artifactId>
    <version>1.0</version>
    <name>A Name</name>
    <description>Description</description>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.MyClient</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

它在干净安装时提供以下消息:

`ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.1.0:shade (default) on project xxxx: Execution default of goal org.apache.maven.plugins:maven-shade-plugin:3.1.0:shade failed: Plugin org.apache.maven.plugins:maven-shade-plugin:3.1.0 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-shade-plugin:jar:3.1.0 -> org.apache.maven:maven-plugin-api:jar:3.0 -> org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2 -> org.codehaus.plexus:plexus-component-annotations:jar:1.6: Failed to read artifact descriptor for org.codehaus.plexus:plexus-component-`annotations:jar:1.6: Could not transfer artifact org.codehaus.plexus:plexus-component-annotations:pom:1.6 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help

1 个答案:

答案 0 :(得分:2)

您的Maven正在尝试从位于https://repo.maven.apache.org/maven2 Maven Central Repository 下载间接依赖项,这是一个安全的HTTP服务器(HTTPS)。也许您的Java安装上有一些证书问题,或者网络基础设施上的某些安全规则阻止了访问。

首先尝试在您的浏览器上访问该URL,并检查它是否可以运行。 如果您可以访问该网站,则问题不在您的网络上。可能的是,您需要以某种方式修复Java可信证书列表才能接受该服务器。看看这个问题/答案:"PKIX path building failed" and "unable to find valid certification path to requested target"

但是,如果你真的无法访问使用HTTPS的Maven Central Repo 您的浏览器,也许是因为您背后的某些代理规则阻止您下载服务器证书。当然,它也不会与Maven合作。然后,看看另一个问题/答案:Problems using Maven and SSL behind proxy