[英]repositories vs pluginRepositories in maven settings.xml
I have the below settings.xml file in my ~/.m2/ folder:我的~/.m2/文件夹中有以下 settings.xml 文件:
<settings>
<profiles>
<profile>
<id>my-repositories</id>
<repositories>
<repository>
<id>thirdparty-repository</id>
<name>Thirdparty repository</name>
<url>https://mynexus/repository/thirdparty/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>thirdparty-plugin-repository</id>
<name>Thirdparty plugin repository</name>
<url>https://mynexus/repository/thirdparty/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>my-repositories</activeProfile>
</activeProfiles>
</settings>
For both repositories the same nexus group repository is used:对于两个存储库,使用相同的关系组存储库:
https://mynexus/repository/thirdparty/ https://mynexus/repository/thirdparty/
If I remove the first one: thirdparty-repository
I get the below error:如果我删除第一个:
thirdparty-repository
我收到以下错误:
Failed to read artifact descriptor for junit:junit:jar:4.8.2: Could not transfer artifact junit:junit:pom:4.8.2 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Now If I re-enable it and instead remove the other one: thirdparty-plugin-repository
I now get this error:现在,如果我重新启用它并删除另一个:
thirdparty-plugin-repository
我现在收到此错误:
Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Only when I have them both enabled at the same time it works.只有当我同时启用它们时它才能工作。
Why do I need both repositories
and pluginRepositories
that points to the same nexus repository?为什么我需要指向同一个 nexus 存储库的
repositories
和pluginRepositories
?
Suppose that you had defined a plugin with some dependencies.假设您已经定义了一个带有一些依赖项的插件。 These dependencies will be searched in all of your
<pluginRepository>
definitions.这些依赖项将在您的所有
<pluginRepository>
定义中进行搜索。 Something like this:像这样的东西:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<dependencies>
<dependency>
<groupId>io.herd.common</groupId>
<artifactId>common-herd</artifactId>
<version>${common.version}</version>
</dependency>
</dependencies>
</plugin>
Even if you have a <repository>
defined which contains the common-herd artifact, Maven will not downloaded it unless you also have a <pluginRepository>
containing it.即使您定义了一个包含common-herd工件的
<repository>
,Maven 也不会下载它,除非您也有一个包含它的<pluginRepository>
。 And of course, the common-herd artifact can not be present inside the Maven Central Repository.当然,普通工件不能出现在 Maven 中央存储库中。
I had this problem a few months ago and Maven only downloaded the specific plugin dependency after I added a <pluginRepository>
几个月前我遇到了这个问题,Maven 在我添加
<pluginRepository>
后才下载了特定的插件依赖项
I had a pb like this, idk if it will help but with this code in my POM.xml my nexus pb were resolved我有一个像这样的 pb,idk 如果它有帮助,但是在我的 POM.xml 中使用此代码,我的 nexus pb 已解决
<distributionManagement>
<repository>
<id>nexus</id>
<name>releases</name>
<url>https://mynexus/repository/thirdparty/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>Snapshots</name>
<url>https://mynexus/repository/thirdparty/</url>
</snapshotRepository>
</distributionManagement>
and和
<!-- download artifacts from this repo -->
<repositories>
<repository>
<id>nexus</id>
<name>Public</name>
<url>https://mynexus/repository/thirdparty/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
hope it helped希望它有所帮助
In Nexus there is defined a public group which should contain all needed repositories and there should no need to configure this in your own pom nor in the settings.xml file.在 Nexus 中定义了一个公共组,它应该包含所有需要的存储库,并且不需要在您自己的 pom 或 settings.xml 文件中配置它。 Only the public group of Nexus should be configured
只应配置 Nexus 的公共组
The only thing you need is to change the url in mirror with your own location...您唯一需要做的就是用您自己的位置更改镜像中的 url...
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.