linux - 安装maven

1. 下载

https://maven.apache.org/download.cgi
进入官网,download栏目,下载 apache-maven-3.8.4-bin.tar.gz,上传到linux服务器

2. 进入文件目录,解压

z代表gzip的压缩包;x代表解压;v代表显示过程信息;f代表后面接的是文件
tar -zxvf apache-maven-3.8.4-bin.tar.gz

3. 配置环境变量 vim /etc/profile

export MAVEN_HOME=/usr/local/maven/apache-maven-3.8.5
export PATH=$MAVEN_HOME/bin:$PATH 

4. 刷新环境变量 source /etc/profile

source /etc/profile

5. 验证

mvn -v 
显示版本说明配置成功

6. 更改镜像源

配置settings.xml,阿里云镜像,黏贴如下代码到 中

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

在settings中配置本地仓库

<localRepository>/usr/local/apache-maven-3.8.4/repository</localRepository>

profile编译配置,在 中

<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>

注意
maven在3.8.1 的默认配置文件中增加了一组标签,如果仓库镜像是http 而不是https 就会被拦截禁止访问,而当前公司私服一般是http 而不支持https.

注释如下代码

<mirror>
  <id>maven-default-http-blocker</id>
  <mirrorOf>external:http:*</mirrorOf>
  <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
  <url>http://0.0.0.0/</url>
  <blocked>true</blocked>
</mirror>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值