linux-centos7 安装 maven 代码管理工具,以及常见配置

1,安装

1,点击下载 maven 安装包,这里选择 3 版本

2,上传到 linux 系统自己有权限的目录,这里选择 /root

3,解压,并移动为 /usr/local/maven

cd /root
tar -zxvf apache-maven-3.6.3-bin.tar.gz
mv apache-maven-3.6.3 /usr/local/maven

4,配置环境变量,这里修改全局文件:vim /etc/profile

在文件的最后一行插入代码:PATH=$PATH:/usr/local/maven/bin

5,让配置文件生效:source /etc/profile

6,测试是否正确安装:mvn -v

2,配置文件,修改本地仓库地址,修改仓库为阿里云

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <!-- 本地 JAR 包 保存地址 -->
    <localRepository>/usr/local/maven/jar</localRepository>

        <pluginGroups></pluginGroups>

        <proxies></proxies>

        <servers></servers>

    <!-- 远程仓库, 由于国外网络的原因,建议使用阿里云的仓库 -->
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>

    <!-- 配置创建项目的版本默认为 JDK8,默认5 -->
    <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>
</settings>

猜你喜欢

转载自www.cnblogs.com/lovling/p/12510558.html
今日推荐