Linux(CentOS 7)下安装配置Maven3.9.2

Linux(CentOS 7)下安装配置Maven3.9.2

环境

  • JDK 1.8+
  • OS:Centos 7.5

下载

apache-maven-3.9.2-bin.tar.gz
https://maven.apache.org/download.cgi
Linux(CentOS 7)下安装配置Maven3.9.2_第1张图片

安装步骤

公共服务,将maven安装在root用户下。

# 创建maven安装地址
mkdir -p /opt/software/maven;

# 解压安装包
tar -zxvf /opt/apache-maven-3.9.2-bin.tar.gz -C /opt/software/maven;
# 配置软链接,通过软链接来配置环境变量
ln -nsf /opt/software/maven/apache-maven-3.9.2 /opt/software/maven/apache-maven;

# 创建本地仓库
mkdir -p /opt/m2/repository;

# 配置settings-- 文件下有个简版可用的配置文件实例
vim /opt/software/maven/apache-maven/conf/settings.xml

# 配置环境变量

vim /etc/profile

export MAVEN_HOME=/opt/software/maven/apache-maven
export PATH=$MAVEN_HOME/bin:$PATH

source /etc/profile

# 检测配置环境
mvn -version

Apache Maven 3.9.2 (c9616018c7a021c1c39be70fb2843d6f5f9b8a1c)
Maven home: /opt/software/maven/apache-maven
Java version: 1.8.0_131, vendor: Oracle Corporation, runtime: /opt/software/jdk1.8.0_131/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.25.4.el7.x86_64", arch: "amd64", family: "unix"

settings.xml内容



<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">

    <localRepository>/opt/m2/repositorylocalRepository>

    <pluginGroups>
    pluginGroups>

    <proxies>
    proxies>

    <servers>
    servers>

    <mirrors>
        <mirror>
            <id>aliyunmavenid>
            <mirrorOf>*mirrorOf>
            <name>阿里云公共仓库name>
            <url>https://maven.aliyun.com/repository/publicurl>
        mirror>
    mirrors>

    <profiles>
        <profile>
            <id>jdk-1.8id>
            <activation>
                <activeByDefault>trueactiveByDefault>
                <jdk>1.8jdk>
            activation>
            <properties>
                <maven.compiler.source>1.8maven.compiler.source>
                <maven.compiler.target>1.8maven.compiler.target>
                <maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
            properties>
        profile>

        <profile>
            <id>aliyunid>
            <activation>
                <activeByDefault>trueactiveByDefault>
                <jdk>1.8jdk>
            activation>
            <properties>
                <maven.compiler.source>1.8maven.compiler.source>
                <maven.compiler.target>1.8maven.compiler.target>
                <maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
            properties>
            <repositories>
                <repository>
                    <id>aliyun_maven_repoid>
                    <url>https://maven.aliyun.com/repository/publicurl>
                    <releases>
                        <enabled>trueenabled>
                        <updatePolicy>alwaysupdatePolicy>
                        <checksumPolicy>warnchecksumPolicy>
                    releases>
                    <snapshots>
                        <enabled>trueenabled>
                        <updatePolicy>alwaysupdatePolicy>
                        <checksumPolicy>warnchecksumPolicy>
                    snapshots>
                repository>
            repositories>
        profile>
    profiles>
settings>

你可能感兴趣的:(Linux,软件安装配置,linux,centos,运维)