maven的配置常见问题

来源:互联网 发布:mac安装win10 不断重启 编辑:程序博客网 时间:2024/04/30 06:19

本文是对maven的配置文件进行修改,即在maven的安装目录的conf->setting.xml下进行操作的。

1:maven修改默认本地仓库
maven的默认本地仓库为C:\Users\Administrator.m2\repository。在一定条件下需要修改。

在maven的setting.xml中配置

<localRepository>F:\maven\apache-maven-3.3.9\repository</localRepository>

F:\maven\apache-maven-3.3.9\repository为你需要修改的路径

2:修改默认JDK版本
使用maven新建项目时,默认使用的JDK版本为1.5;而目前默认版本的JDK已经不能满足我们的开发需要,下面我以1.8为例修改maven的默认JDK版本设置

在setting.xml文件的 <profiles></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> 

3:下载速度过慢的问题
maven默认的搜索引擎会出现下载过慢的问题,对此我们需要在setting.xml文件的<mirrors></mirrors>标签下添加如下代码

<mirror>       <id>alimaven</id>       <mirrorOf>central</mirrorOf>      <name>aliyun maven</name>      <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>      </mirror>

4:使用idea开发工具的自带maven时,pom.xml添加包时会有些包找不到
那是因为idea的自带maven缺少setting.xml文件,下载对应的setting.xml文件放在maven的默认路径的C:\Users\Administrator.m2\中就可以了

0 0
原创粉丝点击