配置Mac访问Nexus自制证书的maven仓库
前提条件 1.Nexus 服务器已经设置成功好了,可以远程访问
前提条件 2. maven本地仓库已经设置为nexus.example.com
alimaven example nexus maven https://nexus.example.com:8443/repository/maven-group/ centralmaven仓库配置优先级
需要注意的是:局部配置优先于全局配置。
配置优先级从高到低:pom.xml> user settings > global settings
如果这些文件同时存在,在应用配置时,会合并它们的内容,如果有重复的配置,优先级高的配置会覆盖优先级低的。
问题
从Mac Pro 访问 nexus 服务器访问maven 仓库遇到了错误
[ERROR] Failed to execute goal on project springboot-jpa: Could not resolve dependencies for project com.us:springboot-jpa:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.springframework.boot:spring-boot-starter-data-jpa:jar:1.3.0.RELEASE: Failed to read artifact descriptor for org.springframework.boot:spring-boot-starter-data-jpa:jar:1.3.0.RELEASE: Could not transfer artifact org.springframework.boot:spring-boot-starter-data-jpa:pom:1.3.0.RELEASE from/to alimaven (https://nexus.cityworks.cn:8443/repository/maven-group/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
解决办法
把nexus 上的证书添加到Mac 电脑上的Java keystore里
openssl x509 -in <(openssl s_client -connect nexus.example.com:8443 -prexit 2>/dev/null) -out ~/nexus.example.com.crt
sudo keytool -importcert -file ~/nexus.example.com.crt -alias nexus -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -storepass changeit
我本机的目录是如下:
sudo keytool -importcert -file ~/nexus.example.com.crt -alias nexus -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre/lib/security/cacerts -storepass changeit
这里有个坑. sudo 第一次输入的是你的Mac Pro 的用户密码,后面的是要输入 密码changeit ,这个是java keystore默认密码,如果不是changeit 就是changeme
测试
:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.us:springboot-jpa >------------------------
[INFO] Building springboot-jpa 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-data-jpa/1.3.0.RELEASE/spring-boot-starter-data-jpa-1.3.0.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-data-jpa/1.3.0.RELEASE/spring-boot-starter-data-jpa-1.3.0.RELEASE.pom (2.1 kB at 754 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-aop/1.3.0.RELEASE/spring-boot-starter-aop-1.3.0.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-aop/1.3.0.RELEASE/spring-boot-starter-aop-1.3.0.RELEASE.pom (1.2 kB at 3.0 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/aspectj/aspectjweaver/1.8.7/aspectjweaver-1.8.7.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/aspectj/aspectjweaver/1.8.7/aspectjweaver-1.8.7.pom (1.0 kB at 2.5 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-jdbc/1.3.0.RELEASE/spring-boot-starter-jdbc-1.3.0.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-jdbc/1.3.0.RELEASE/spring-boot-starter-jdbc-1.3.0.RELEASE.pom (1.2 kB at 2.6 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-jdbc/8.0.28/tomcat-jdbc-8.0.28.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-jdbc/8.0.28/tomcat-jdbc-8.0.28.pom (1.5 kB at 3.9 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-juli/8.0.28/tomcat-juli-8.0.28.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-juli/8.0.28/tomcat-juli-8.0.28.pom (1.3 kB at 3.4 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/logging/jboss-logging-tools-parent/1.2.0.Beta1/jboss-logging-tools-parent-1.2.0.Beta1.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/logging/jboss-logging-tools-parent/1.2.0.Beta1/jboss-logging-tools-parent-1.2.0.Beta1.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/jboss-parent/10/jboss-parent-10.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/jboss-parent/10/jboss-parent-10.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/dom4j/dom4j/1.6.1/dom4j-1.6.1.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/dom4j/dom4j/1.6.1/dom4j-1.6.1.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.pom (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-jpa/1.9.1.RELEASE/spring-data-jpa-1.9.1.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-jpa/1.9.1.RELEASE/spring-data-jpa-1.9.1.RELEASE.pom (14 kB at 34 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/build/spring-data-parent/1.7.1.RELEASE/spring-data-parent-1.7.1.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/build/spring-data-parent/1.7.1.RELEASE/spring-data-parent-1.7.1.RELEASE.pom (22 kB at 55 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-framework-bom/4.1.8.RELEASE/spring-framework-bom-4.1.8.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-framework-bom/4.1.8.RELEASE/spring-framework-bom-4.1.8.RELEASE.pom (5.1 kB at 13 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-commons/1.11.1.RELEASE/spring-data-commons-1.11.1.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-commons/1.11.1.RELEASE/spring-data-commons-1.11.1.RELEASE.pom (6.8 kB at 17 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-orm/4.2.3.RELEASE/spring-orm-4.2.3.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-orm/4.2.3.RELEASE/spring-orm-4.2.3.RELEASE.pom (7.3 kB at 19 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-aspects/4.2.3.RELEASE/spring-aspects-4.2.3.RELEASE.pom
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-aspects/4.2.3.RELEASE/spring-aspects-4.2.3.RELEASE.pom (3.6 kB at 9.1 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-data-jpa/1.3.0.RELEASE/spring-boot-starter-data-jpa-1.3.0.RELEASE.jar
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-jdbc/1.3.0.RELEASE/spring-boot-starter-jdbc-1.3.0.RELEASE.jar
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-jdbc/8.0.28/tomcat-jdbc-8.0.28.jar
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/aspectj/aspectjweaver/1.8.7/aspectjweaver-1.8.7.jar
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-aop/1.3.0.RELEASE/spring-boot-starter-aop-1.3.0.RELEASE.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-data-jpa/1.3.0.RELEASE/spring-boot-starter-data-jpa-1.3.0.RELEASE.jar (2.4 kB at 4.6 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-juli/8.0.28/tomcat-juli-8.0.28.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-juli/8.0.28/tomcat-juli-8.0.28.jar (41 kB at 38 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-aop/1.3.0.RELEASE/spring-boot-starter-aop-1.3.0.RELEASE.jar (2.2 kB at 1.6 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/boot/spring-boot-starter-jdbc/1.3.0.RELEASE/spring-boot-starter-jdbc-1.3.0.RELEASE.jar (2.2 kB at 1.3 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.jar (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/apache/tomcat/tomcat-jdbc/8.0.28/tomcat-jdbc-8.0.28.jar (136 kB at 63 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-jpa/1.9.1.RELEASE/spring-data-jpa-1.9.1.RELEASE.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-commons/1.11.1.RELEASE/spring-data-commons-1.11.1.RELEASE.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar (0 B at 0 B/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-orm/4.2.3.RELEASE/spring-orm-4.2.3.RELEASE.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/aspectj/aspectjweaver/1.8.7/aspectjweaver-1.8.7.jar (1.9 MB at 502 kB/s)
Downloading from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-aspects/4.2.3.RELEASE/spring-aspects-4.2.3.RELEASE.jar
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-aspects/4.2.3.RELEASE/spring-aspects-4.2.3.RELEASE.jar (58 kB at 14 kB/s)
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/spring-orm/4.2.3.RELEASE/spring-orm-4.2.3.RELEASE.jar (466 kB at 100 kB/s)
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar (0 B at 0 B/s)
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-commons/1.11.1.RELEASE/spring-data-commons-1.11.1.RELEASE.jar (638 kB at 119 kB/s)
Downloaded from alimaven: https://nexus.example.com:8443/repository/maven-group/org/springframework/data/spring-data-jpa/1.9.1.RELEASE/spring-data-jpa-1.9.1.RELEASE.jar (255 kB at 44 kB/s)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ springboot-jpa ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springboot-jpa ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /Volumes/linyingjie2/example-study/spring-security/springBoot/springboot-jpa/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.890 s
[INFO] Finished at: 2019-05-31T10:30:02+08:00
[INFO] ----------------------------------------
至此,测试成功.