尝试运行 mvnd clean install 时出现此错误:
[ERROR] The project com.exmpale:my-project:SP-21.053.00_-SNAPSHOT (/home/username/IdeaProjects/my-project/pom.xml) has 1 error
[ERROR] Non-resolvable import POM: The following artifacts could not be resolved: org.assertj:assertj-bom:pom:3.25.0 (absent): Could not transfer artifact org.assertj:assertj-bom:pom:3.25.0 from/to public (https://nexus-ci.com
/repository/public/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target @ line 5739, column 19 -> [Help 2]
我能够通过在项目根目录中添加 .mvn/jvm.config 来解决 maven 问题:
-Dmaven.wagon.http.ssl.ignore.validity.dates=true
-Dmaven.wagon.http.ssl.allowall=true
-Dmaven.wagon.http.ssl.insecure=true
对于 mvnd,我尝试将这些属性添加到:
设置.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>/home/username/.m2/repository</localRepository>
<profiles>
<profile>
<id>default</id>
<properties>
<maven.wagon.http.ssl.allowall>true</maven.wagon.http.ssl.allowall>
<maven.wagon.http.ssl.insecure>true</maven.wagon.http.ssl.insecure>
<maven.wagon.http.ssl.ignore.validity.dates>true</maven.wagon.http.ssl.ignore.validity.dates>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<!-- other tags are omitted -->
</settings>
项目根目录下的.mvn/maven.config:
-Dmaven.wagon.http.ssl.ignore.validity.dates=true
-Dmaven.wagon.http.ssl.allowall=true
-Dmaven.wagon.http.ssl.insecure=true
jvmArgs 属性中的 .mvnd.properties:
mvnd.jvmArgs=-Dmaven.wagon.http.ssl.ignore.validity.dates=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.insecure=true
并通过终端传递它们:
mvnd clean install -Dmaven.wagon.http.ssl.ignore.validity.dates=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.insecure=true
但没有任何帮助。
mvn --版本
Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39)
Maven home: /opt/apache-maven-3.8.8
Java version: 1.8.0_282, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u282-b08/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.7.1-amd64", arch: "amd64", family: "unix"
mvnd --版本
Apache Maven Daemon (mvnd) 1.0.2 linux-amd64 native client (cccc1ec8a5b741c62b29f9fb04d37b1678a029bb)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jni.linux.LinuxNativePty
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /home/username/maven-mvnd-1.0.2-linux-amd64/mvn
Java version: 1.8.0_282, vendor: AdoptOpenJDK, runtime: /usr/lib/jvm/jdk8u282-b08/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.7.1-amd64", arch: "amd64", family: "unix"
我无法解决该问题,但我找到了解决方法:
do
mvn clean install
下载构建项目所需的所有依赖项
do
mvnd -nsu -o clean install
以离线模式运行 mvnd
如果出现错误,表明缺少某些依赖项,例如:
[ERROR] dependency: org.mockito:mockito-core:jar:1.9.5 (provided)
[ERROR] Cannot access public (https://nexus-ci.com/repository/public/) in offline mode and the artifact org.mockito:mockito-core:jar:1.9.5 has not been downloaded from it before.
只需下载所需的依赖项:
mvn dependency:get -DgroupId=org.mockito -DartifactId=mockito-core -Dversion=1.9.5
然后再做一次
mvnd -nsu -o clean install