Maven
安装
- 在官方连接中下载合适版本的maven,3.9.x版本可能会出现旧jar包不兼容情况。https://maven.apache.org/docs/history.html
- 解压缩到安装目录(全英文路径),并配置环境变量。
系统环境变量的变量名:MAVEN_HOME
变量值:maven 的安装目录。
将MAVEN_HOME添加的path系统变量
- 应用环境变量后,打开新的CMD窗口,输入命令判断是否安装成功。
mvn -v
配置成功的输出
镜像
使用镜像时,尽量仅使用一个镜像仓库,不要同时配置多个镜像仓库,可能出现冲突。
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
配置编译项目
<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>
</profiles>
注意
出现plugin 未下载成功在xml中添加
<parent>
<relativePath />
</parent>
其他情况可能为plugin未确定版本号
在<parent>中添加版本号
或更改镜像:使用且仅使用官方镜像
<mirror>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>