一、问题
maven从远程maven源下载依赖jar报错: the trustAnchors parameter must be non-empty,错误详细内容如下:
Could not transfer artifact com.google.code.gson:gson:pom:2.10.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
二、错误原因
主要是带有 https 仓库认证不通过 (maven 的setting文件中配置的远程maven源)
三、解决方法:忽略ssl证书检验即可,cmd命令窗口执行如下命令:
mvn clean && mvn compile -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
##执行上面命令不成功,产生分支问题一,报错信息如下:
Maven报错 The goal you specified requires a project to execute but there is no POM in this directory
(1)分支问题解决参考:
https://blog.youkuaiyun.com/qq_61960296/article/details/136665249
和
Maven官方入门教程链接
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
每个参数增加"",再次执行命令,仍然报错:
mvn clean && mvn compile "-Dmaven.wagon.http.ssl.insecure=true" "-Dmaven.wagon.http.ssl.allowall=true" "-Dmaven.wagon.http.ssl.ignore.validity.dates=true"
(2)分支问题一继续解决:
##在IDE工具IDEA上增加上面参数,继续报错,参考:https://blog.youkuaiyun.com/kai563596378/article/details/112699671
(3)分支问题一解决:在当前工程目录下(pom文件所在的目录)执行cmd命令,再执行
mvn clean && mvn compile -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
分支问题一解决。
四、继续当前工程通过maven更新依赖,继续报错,产生分支问题二:
Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:3.2.5 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
工程问题如下图:
问题原因:maven配置错误,本地仓库路径和setting文件不一致
分支问题二解决:修改maven的setting文件,本地仓库路径一致即可
五、然后继续maven Reload project,继续报错,产生分支问题三:
com.google.guava:guava:jar:32.1.3-jre failed to transfer from https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact com.google.guava:guava:jar:32.1.3-jre from/to central (https://repo.maven.apache.org/maven2): Premature end of Content-Length delimited message body (expected: 3,043,932; received: 2,522,372)
问题原因:无法从远程maven源下载依赖(com.google.guava:guava:jar:32.1.3-jre)
尝试解决:
(1)删除本地下载失败的jar
C:\appinstall\maven\localRepository>for /r %i in (*.lastUpdated) do del %i
(2)继续maven Reload project
反复几次,一致报错。
分支问题三原因:com.google.guava:guava:jar:32.1.3-jre依赖的是OracleJDK,而我本地安装的是openJDK,用openJDK,证书验证不通过。
分支问题三解决:本地安装OracleJDK,并在IDE上设置。
至此,全部问题解决,工程跑起来了。