maven学习
整理 Maven 坐标、settings 文件、profile 优先级、仓库选择与阿里云镜像配置。
Maven坐标定义了一组标识,它们可以用来唯一标识一个项目,一个依赖,或者Maven POM里的一个插件。 groupId, artifactId, version和packaging的组合代表一个坐标, maven通过坐标来精确定位一个项目.
maven的相关配置一般在~/.m2下面, 通常包括一个settings.xml配置文件和repository的文件夹, 文件夹中是下载下来分类放置的jar包.
settings.xml详解(挺详细的, 自己懒得写(抄)…) http://blog.csdn.net/stypace/…
关于profile http://elim.iteye.com/blog/19… 需要注意的是
<profiles> <profile> <id>profileTest1</id> ... </profile> <profile> <id>profileTest2</id> ... </profile></profiles><activeProfiles> <activeProfile>profileTest2</activeProfile> <activeProfile>profileTest1</activeProfile></activeProfiles>Profile的优先级是越晚定义优先级越高, 也就是后面一个profile会覆盖前一个, 即会优先使用最后定义的一个. 若是把内部远程库写到最后一个, 当不在内部网络环境中时, 会造成阻塞很长时间!
maven仓库优先级
http://ttxsj.iteye.com/blog/2…
简要描述:
本地仓库 > settings.xml中的profile > pom中的repository > mirror
但将mirrorOf设为“*“会导致所有仓库均以该mirror为镜像, 只在mirror里找, 会导致pom文件中、profile里面的仓库设置都失效. 一般情况设置中央仓库的镜像即可.
将aliyun的maven仓库作为中央仓库的镜像, 可以显著提升下载速度
<mirrors> <mirror> <id>nexus-aliyun</id> <mirrorOf>central</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror></mirror>