linux(CentOS7)maven使用错误
1、maven代理错误
错误提示:
[root@host-192-144-7-141 guacamole-client-1.1.0]# mvn package [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] guacamole-common [jar] [INFO] guacamole-ext [jar] [INFO] guacamole-common-js [pom] [INFO] guacamole [war] [INFO] guacamole-auth-cas [jar] [INFO] guacamole-auth-duo [jar] [INFO] guacamole-auth-header [jar] [INFO] guacamole-auth-jdbc [pom] [INFO] guacamole-auth-jdbc-base [jar] [INFO] guacamole-auth-jdbc-mysql [jar] [INFO] guacamole-auth-jdbc-postgresql [jar] [INFO] guacamole-auth-jdbc-sqlserver [jar] [INFO] guacamole-auth-jdbc-dist [jar] [INFO] guacamole-auth-ldap [jar] [INFO] guacamole-auth-openid [jar] [INFO] guacamole-auth-quickconnect [jar] [INFO] guacamole-auth-totp [jar] [INFO] guacamole-example [war] [INFO] guacamole-playback-example [war] [INFO] guacamole-client [pom] [INFO] [INFO] ---------------< org.apache.guacamole:guacamole-common >---------------- [INFO] Building guacamole-common 1.1.0 [1/20] [INFO] --------------------------------[ jar ]--------------------------------- Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/2.4/maven-source-plugin-2.4.pom [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for guacamole-client 1.1.0: [INFO] [INFO] guacamole-common ................................... FAILURE [ 30.458 s] [INFO] guacamole-ext ...................................... SKIPPED [INFO] guacamole-common-js ................................ SKIPPED [INFO] guacamole .......................................... SKIPPED [INFO] guacamole-auth-cas ................................. SKIPPED [INFO] guacamole-auth-duo ................................. SKIPPED [INFO] guacamole-auth-header .............................. SKIPPED [INFO] guacamole-auth-jdbc ................................ SKIPPED [INFO] guacamole-auth-jdbc-base ........................... SKIPPED [INFO] guacamole-auth-jdbc-mysql .......................... SKIPPED [INFO] guacamole-auth-jdbc-postgresql ..................... SKIPPED [INFO] guacamole-auth-jdbc-sqlserver ...................... SKIPPED [INFO] guacamole-auth-jdbc-dist ........................... SKIPPED [INFO] guacamole-auth-ldap ................................ SKIPPED [INFO] guacamole-auth-openid .............................. SKIPPED [INFO] guacamole-auth-quickconnect ........................ SKIPPED [INFO] guacamole-auth-totp ................................ SKIPPED [INFO] guacamole-example .................................. SKIPPED [INFO] guacamole-playback-example ......................... SKIPPED [INFO] guacamole-client ................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 30.666 s [INFO] Finished at: 2020-03-13T14:29:43+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-source-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-source-plugin:jar:2.4: Could not transfer artifact org.apache.maven. plugins:maven-source-plugin:pom:2.4 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/2.4/maven-source-plugin-2.4.pom: Unknown host repo.maven.apache.org: 未知的名称或服务 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
可以看到在【ERROR】最后一行有报错:
Unknown host repo.maven.apache.org: 未知的名称或服务 ->
说明maven访问不到 repo.maven.apoache.org
原因分析:
机器的网络访问方式为,环境中的虚拟机通过代理访问安全PC,安全PC再通过huawei.proxy访问外网。此过程中存在访问失败。
解决方法:
沿着访问路径,可以通过curl或者浏览器逐一尝试访问maven的目的地址。发现各个机器均能够访问到目的地址,说明是maven自身的问题。
查询发现,maven自身也需要设置代理,代理设置位置为/maven/conf/settings.xml,在其中添加以下设置项即可:
<proxy> <active>true</active> <protocol>https</protocol> <host>192.144.3.79</host> <port>808</port> <nonProxyHosts>maven</nonProxyHosts> </proxy>
2、没有有效证书
错误提示:
[root@host-192-144-7-141 guacamole-client-1.1.0]# mvn package [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] guacamole-common [jar] [INFO] guacamole-ext [jar] [INFO] guacamole-common-js [pom] [INFO] guacamole [war] [INFO] guacamole-auth-cas [jar] [INFO] guacamole-auth-duo [jar] [INFO] guacamole-auth-header [jar] [INFO] guacamole-auth-jdbc [pom] [INFO] guacamole-auth-jdbc-base [jar] [INFO] guacamole-auth-jdbc-mysql [jar] [INFO] guacamole-auth-jdbc-postgresql [jar] [INFO] guacamole-auth-jdbc-sqlserver [jar] [INFO] guacamole-auth-jdbc-dist [jar] [INFO] guacamole-auth-ldap [jar] [INFO] guacamole-auth-openid [jar] [INFO] guacamole-auth-quickconnect [jar] [INFO] guacamole-auth-totp [jar] [INFO] guacamole-example [war] [INFO] guacamole-playback-example [war] [INFO] guacamole-client [pom] [INFO] [INFO] ---------------< org.apache.guacamole:guacamole-common >---------------- [INFO] Building guacamole-common 1.1.0 [1/20] [INFO] --------------------------------[ jar ]--------------------------------- Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-source-plugin/2.4/maven-source-plugin-2.4.pom [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for guacamole-client 1.1.0: [INFO] [INFO] guacamole-common ................................... FAILURE [ 1.013 s] [INFO] guacamole-ext ...................................... SKIPPED [INFO] guacamole-common-js ................................ SKIPPED [INFO] guacamole .......................................... SKIPPED [INFO] guacamole-auth-cas ................................. SKIPPED [INFO] guacamole-auth-duo ................................. SKIPPED [INFO] guacamole-auth-header .............................. SKIPPED [INFO] guacamole-auth-jdbc ................................ SKIPPED [INFO] guacamole-auth-jdbc-base ........................... SKIPPED [INFO] guacamole-auth-jdbc-mysql .......................... SKIPPED [INFO] guacamole-auth-jdbc-postgresql ..................... SKIPPED [INFO] guacamole-auth-jdbc-sqlserver ...................... SKIPPED [INFO] guacamole-auth-jdbc-dist ........................... SKIPPED [INFO] guacamole-auth-ldap ................................ SKIPPED [INFO] guacamole-auth-openid .............................. SKIPPED [INFO] guacamole-auth-quickconnect ........................ SKIPPED [INFO] guacamole-auth-totp ................................ SKIPPED [INFO] guacamole-example .................................. SKIPPED [INFO] guacamole-playback-example ......................... SKIPPED [INFO] guacamole-client ................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.201 s [INFO] Finished at: 2020-03-13T15:36:00+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-source-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-source-plugin:jar:2.4: Could not transfer artifact org.apache.maven.plugins:maven-source-plugin :pom:2.4 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for plugins/maven-source-plugin/2.4/maven-source-plugin-2.4.pom ProxyInfo{host='192.144.3.79', userName='null', port=808, type='http', nonProxyHosts='null'}: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath. SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
可以看到最长一行[ERROR]里面有提示:
unable to find valid certification path to requested target
即没有有效证书来访问目标路径
解决方法:
解决方法一共有三种,第一种为生成并添加证书,第二种为改访问使用HTTP 的镜像,第三种为强行跳过检验
1.通过浏览器生成证书,并作为参数传给maven
Chrome 访问 https://repo.maven.apache.org/
F12 后在
Security -> View certificate -> 详细信息 -> 复制到文件(C)...
导出证书,格式选择Base 64 编码 X.509 (.CER)
执行
keytool -import -file C:\mavenCert.cer -keystore C:\mavenKeystore
后续再执行
mvn
命令时需要带个参数-Djavax.net.ssl.trustStore=C:\mavenKeystore
,比如这样mvn install -Djavax.net.ssl.trustStore=C:\mavenKeystore
2.更改中心库配置为HTTP协议能够访问的镜像
在settings.xml文件中添加中心库的配置。
<mirrors> <mirror> <id>Central</id> <url>http://repo1.maven.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
3. 强行跳过检验
可以依次尝试在命令后添加以下参数来取消验证
-Dmaven.wagon.http.ssl.insecure=true
- enable use of relaxed SSL check for user generated certificates.-Dmaven.wagon.http.ssl.allowall=true
- enable match of the server's X.509 certificate with hostname. If disabled, a browser like check will be used.-Dmaven.wagon.http.ssl.ignore.validity.dates=true
- ignore issues with certificate dates.
参考:
- 点赞
- 收藏
- 关注作者
评论(0)