一、maven配置本地仓库
maven的默认路径在用户目录的.m2文件夹里面(C:Usersadmin.m2),当maven本地依赖比较多的时候,会造成C盘文件较大,需要修改maven的本地仓库的路径。
步骤如下:
打开maven的 c o n f color{red}conf conf文件夹,找到里面的 s e t t i n g . x m l color{red}setting.xml setting.xml文件:
<localRepository>D:\maven\maven-Repository</localRepository>
二、maven配置国内镜像
maven的默认镜像是http://my.repository.com/repo/path,服务器在国外,一般项目构建如果使用这个镜像会十分缓慢,所以需要采用国内的maven镜像。
在setting.xml配置文件的 < m i r r o r s > color{red} <mirrors>节点内添加如下配置代码:
<!-- 配置阿里云的镜像 -->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
三、配置maven指定的JDK版本
第一种(最省事):在我们安装maven环境的conf目录下修改settings.xml文件,如下:
在profiles中加入以下配置。
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.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>
第二种:在我们开发工具eclipse中添加配置也可以实现,具体配置如下:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
第三种:还是在eclipse中添加配置,和第二种不一样的是我们通过maven的插件实现,
具体配置如下:
<build>
<plugins>
<!-- 设置编译版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>