Maven 核心配置和安装
- Maven 官网首页
https://maven.apache.org/
- 下载页面
https://maven.apache.org/download.cgi
Maven 本地配置
主要关注配置文件中settings
conf/settings.xml
settings.xml 核心配置
- 指定本地仓库
本地仓库默认值:用户家目录/.m2/repository
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<!--自定义本地仓库地址-->
<!-- <localRepository>D:\maven\repository</localRepository> -->
<localRepository>/Users/mwe/maven/repository</localRepository>
- 配置阿里云提供的镜像仓库
<mirrors>
<!--将原有的进行注释(在国内访问速度很慢)-->
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
- 配置Maven 使用的JDK版本
<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>
本地环境变量配置
# 编辑~/.zshrc文件
vim ~/.zshrc
# 添加maven 环境变量
export MAVEN_HOME=/Users/mi/development/maven/apache-maven-3.5.2
export PATH=$PATH:$MAVEN_HOME/bin
# 使配置生效
source ~/.zshrc
mvn -v