Skip to content
All Posts

Maven Notes

A Maven reference for coordinates, settings files, profile precedence, repository selection, and Aliyun mirror configuration.

Maven coordinates define a set of identifiers that uniquely identify a project, dependency, or plugin in a Maven POM. The combination of groupId, artifactId, version, and packaging forms a coordinate, which Maven uses to locate a project precisely.

Maven configuration normally lives under ~/.m2. It typically includes a settings.xml file and a repository directory containing downloaded JAR files organized by coordinate.

A detailed explanation of settings.xml—detailed enough that I will not copy it here: http://blog.csdn.net/stypace/…

About profiles: http://elim.iteye.com/blog/19…

One important detail is profile precedence:

<profiles>
<profile>
<id>profileTest1</id>
...
</profile>
<profile>
<id>profileTest2</id>
...
</profile>
</profiles>
<activeProfiles>
<activeProfile>profileTest2</activeProfile>
<activeProfile>profileTest1</activeProfile>
</activeProfiles>

The later a profile is defined, the higher its priority. A later profile overrides an earlier one, so Maven prefers the last definition. If an internal remote repository is placed in the final profile, Maven may block for a long time when you are outside the internal network.

Maven repository priority: http://ttxsj.iteye.com/blog/2…

In brief:

Local repository > profile in settings.xml > repository in the POM > mirror

However, setting mirrorOf to "*" makes that mirror stand in for every repository. Maven will search only the mirror, making repository settings in both the POM and profiles ineffective. Normally, it is enough to configure a mirror for Maven Central.

Using Aliyun’s Maven repository as a mirror for Maven Central can significantly improve download speed:

<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>

Originally published on SegmentFault.