Maven安装完成之后,在conf/setting.xml中(可以把setting.xml复制到自己的用户目录下更改,以便每个用户的配置都能自定义) 1.配置本地仓库地址,从远程仓库下载的jar包会保存到这个目录,默认会在用户目录;建议自定义目录,方便管理:
<localRepository>/home/daniel/Tools/Maven/repo</localRepository>
2.在mirrors节点中添加远程仓库地址,可多个,以oschina的仓库为例: id, name是该镜像的唯一定义符。id用来区分不同的mirror元素。url是该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 mirrorOf是被镜像的服务器的id。
例如,如果我们要设置了一个Maven中央仓库( http:// repo1.maven.org/maven2)的镜像,就需要将该元素设置成central。这必须和 中央仓库的id central完全一致。
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
3.执行maven时还需要一些插件,下面时配置这些插件的下载地址,和maven默认JDK版本,在profiles节点添加profile
<profile>
<id>jdk1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>