首先打开你下载的Maven文件夹下面con文件夹下面的setting.xml文件,这个文件夹特点,除了一些特定的标签基本都是注释的内容,相当于这个文件夹是空的,需要每个用Maven的程序员去配置它,配置的内容一般都是放在这个xml文夹的标签外或标签内。
一般都要做三个配置:
1、本地仓库配置
标签内的就是仓库(放jar包)位置
<!- 选择一个磁盘目录,作为本地仓库 —>
<localRepository>D:\Program Files\maven\myrepository</localRepository>
2 、JDK配置
找到xml文件下标签<profiles>,在标签内添加如下代码,用来限定maven项目默认的jdk版本.
内容如下:
<profiles>
<!--在已有的profiles标签中添加profile标签--><profile>
<id>myjdk</id>
<activation>
<activeByDefault>true</activeByOefault>
<jdk>l.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
其次,在标签外需要让标签生效
< !--让增加的profile生效-->
<activeProfiles>
octiveProfile>myjdk</activeProfile>
</activeProfiles>
3、公共仓库【重点】
•除中央仓库之外,还有其他远程仓库。比如aliyun仓库(http://maven.aliyun.CQm/nexus/content/groups/public/) •中央仓库在国外,下载依赖速度过慢,所以都会配置一个国内的公共仓库替代中央仓库。注意:在<mirrors>标签内单独在加一个镜像标签。
<mirrors>
<mirror>
<id>aliyun</id>
<!--中心仓库的mirror(镜像)-->
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<!-- aliyun仓库地址 以后所有要指向中心仓库的请求,都会指向aliyun仓库-->
<url>[http://maven.aliyun.com/nexus/content/groups/public>
</mirror>
</mirrors>