我的公司服务器中有Maven repository
,所以我必须使用证书进行连接。
我必须修改我的mvn
命令并添加以下行:
export MAVEN_OPTS=-Djavax.net.ssl.trustStore=/maven/bin/maven.jks
export MAVEN_OPTS=$MAVEN_OPTS -Djavax.net.ssl.trustStorePassword=123456
export MAVEN_OPTS=$MAVEN_OPTS -Djavax.net.ssl.trustStoreType=JKS
export MAVEN_OPTS=$MAVEN_OPTS -Dmaven.wagon.http.ssl.insecure=true
export MAVEN_OPTS=$MAVEN_OPTS -Dmaven.wagon.http.ssl.allowall=true
之后我将此证书添加到我的cacerts
文件中:
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/security/cacerts
我还将我安装的Maven settings.xml文件修改为:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<mirrors>
<mirror>
<id>companyrepo.group</id>
<name>companyrepo.group</name>
<url>https://companyrepo.intra/companyrepo.group</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>companyrepo.group</id>
<url>https://companyrepo.intra/companyrepo.group</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
</activeProfiles>
<proxies>
</proxies>
<servers>
<server>
<id>companyrepo.group</id>
</server>
</servers>
</settings>
并设置我的Eclipse以使用此设置文件。
如果我尝试从我的终端连接此repo,我可以访问,例如,如果我运行mvn package
命令,我可以连接到此repo。
之后我将Eclipse / Preferences / Maven / Installation设置为不使用默认Maven
中的构建,但是如果我打开使用该公司存储库的项目,则会收到以下错误消息:
Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from https://companyrepo.intra/companyrepo.group was cached in the local repository, resolution will not be reattempted until
the update interval of companyrepo.group has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from/to companyrepo.group (https://companyrepo.intra/companyrepo.group): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to
requested target
我应该在哪里设置此jks
以使Eclipse
看到存储库?谢谢!
答案 0 :(得分:0)
MAVEN_OPTS
脚本可以使用mvn
变量,但eclipse插件不使用脚本,而是使用自己的机制来执行maven命令。要将参数传递给maven插件,请在Eclipse中的“编辑配置和启动”对话框中输入:
运行方式&gt; Maven Build &gt;点击 JRE 标签&gt;输入 VM args ,例如
$ {ENV_VAR:MAVEN_OPTS}