I have a Maven project which contains the following dependencyManagement
section:
<dependencyManagement>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myBom</artifactId>
<version>1.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencyManagement>
In my Maven settings.xml
file, I have the following repositories
definition:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>public</name>
<url><pathToArtifactory>/public</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>snapshots</id>
<name>public-snapshots</name>
<url><pathToArtifactory>/public-snapshots</url>
</repository>
</repositories>
However, I keep getting the following error message:
Project Build error: Non-resolvable import POM: Could not find artifact myGroup:myBom:pom:1.0.0 in snapshots (<pathToArtifactory>/public-snapshots)
After having ran a mvn dependency:list-repositories
, I can confirm the repositories are correctly defined, and not somewhere overriden.
Why is Maven looking for a 1.0.0
Version into my SNAPSHOT defined repository?
Maven searches your snapshot repository for releases.
To disable that behaviour, add the following to the snapshot repository in your settings.xml
and see if it works:
<releases>
<enabled>false</enabled>
</releases>
Also, adding Artifactory as amirror instead of a repository should be better. Though I don't know how you'd add snapshots that way.
Ok, found it.. Seems that from Maven 3,5.0 onward, having a server id called central
in settings.xml
is causing problem with the official Maven Central Repository which is as well called central
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.