[英]maven import pom (BOM) own project from internal maven repository
We are trying to group maven dependencies inside a seperate maven POM-typed project. 我们正在尝试将Maven依赖项分组到一个单独的Maven POM类型的项目中。
We would like to use this as both a POM-type dependency inside the dependencies node aswell as a BOM (Bill of Materials) inside the de dependencyManagement. 我们希望将其用作依赖项节点内部的POM类型的依赖项以及dedependencyManagement内部的BOM(物料清单)。
We have an 2 repository inside the company. 我们公司内部有2个存储库。 (Apache Archiva - 2.2.0).
(Apache Archiva-2.2.0)。 One of them is for Snapshots and one of them for releases.
其中之一用于快照,其中之一用于发行。
When I try to use the snapshot version, everything works fine, but when i want to use the released version, i keep getting an error because it keeps looking for the dependency inside the central maven repository (where our pom is not located) 当我尝试使用快照版本时,一切正常,但是当我想使用发布的版本时,我不断收到错误消息,因为它一直在寻找中央Maven存储库(我们的Pom不在其中)内的依赖关系。
To me it seems like the POM-dependency is being searched inside the snapshot repository only. 在我看来,似乎仅在快照存储库中搜索POM依赖项。
<properties>
...
<dependency.bla-slf4j-logback-BOM.version>1.0.1</dependency.bla-slf4j-logback-BOM.version>
...
</properties>
<dependencies>
...
<dependency>
<groupId>my.groupid</groupId>
<artifactId>bla-slf4j-logback-BOM</artifactId>
<version>${dependency.bla-slf4j-logback-BOM.version}</version>
<type>pom</type>
</dependency>
...
</dependencies>
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>my.groupid</groupId>
<artifactId>bla-slf4j-logback-BOM</artifactId>
<version>${dependency.bla-slf4j-logback-BOM.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
...
</dependencies>
</dependencyManagement>
errormessage: 错误信息:
[ERROR] Non-resolvable import POM: Failure to find my.groupid:bla-slf4j-logback-BOM:pom:1.0.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 234, column 22 -> [Help 2]
used command: 使用的命令:
mvn dependency:tree
I checked our archiva, the artifact is present at the expected location. 我检查了我们的档案,工件在预期的位置。 I also checked the local maven directory, the pom dependency was downloaded correctly.
我还检查了本地maven目录,正确下载了pom依赖项。
Any ideas why this doesn't work for a released version of our POM-project (1.0.1), but does work for a Snapshot version (1.0.1-SNAPSHOT) of our POM-project. 任何想法为什么这对我们的POM项目(1.0.1)的发行版不起作用,但对我们的POM项目的快照版本(1.0.1-SNAPSHOT)起作用却不胜枚举。
The solution was to add the following block of xml to the maven settings.xml file. 解决方案是将以下xml块添加到maven settings.xml文件中。
<mirrors>
<mirror>
<id>ourcentral</id>
<name>our central</name>
<url>http://mavenrepourl.goes.here</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
This causes it to check our internal maven repository as the central maven repository. 这导致它将我们的内部Maven存储库检查为中央Maven存储库。 (our maven repository has the default central repository as remote repository)
(我们的maven存储库具有默认的中央存储库作为远程存储库)
Special thanks to: Hisham kh 特别鸣谢:Hisham kh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.