maven安装笔记–Linux系统和win系统
官网
https://maven.apache.org/download.cgi
linux系统安装maven
下载解压
# 下载maven, 不校验证书
wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz --no-check-certificate
# 解压
tar -xvf apache-maven-3.8.6-bin.tar.gz
修改配置文件
vi /etc/profile
# maven
MAVEN_HOME=/java/apache-maven-3.8.6
PATH=$MAVEN_HOME/bin:$PATH
export PATH
运行命令让配置生效
#运行命令让配置生效
source /etc/profile
#完成安装,检查是否正确
mvn -v
设置本地仓库和阿里镜像
# 编辑配置文件
vi conf/settings - server.xml
<!-- 设置本地仓库地址 -->
<localRepository>/java/mavenRepository</localRepository>
<!--设置阿里镜像-->
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
命令行安装一个依赖
mvn dependency:get -DgroupId=junit -DartifactId=junit -Dversion=4.8.2
# 带仓库地址的,没有感觉到区别
mvn dependency:get -DremoteRepositories=http://repo1.maven.org/maven2/ -DgroupId=junit -DartifactId=junit -Dversion=4.8.2
# 安装完成后,去本地仓库地址,可以看到已经下载的依赖jar包
win系统配置maven
# 配置环境变量
# MAVEN_HOME = D:\kf\maven-3.6.3
# path = D:\kf\maven-3.6.3\bin
# 验证是否成功
mvn -v