centos7下安装maven

步骤1:在home目录下解压apache-maven-3.5.0-bin.tar.gz安装包

[root@model ~]# tar -zxvf apache-maven-3.5.0-bin.tar.gz

步骤2:创建/maven目录并将解压后的文件夹移至该目录下

[root@model ~]# mkdir /maven
[root@model ~]# 
[root@model ~]# 
[root@model ~]# mv ~/apache-maven-3.5.0 /maven
[root@model ~]# 

步骤3:配置环境变量文件(加入红色部分)

[root@model etc]# vi /etc/profile
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}


if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

unset i
unset -f pathmunge

JAVA_HOME=/java/jdk1.8.0_141/
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH

export MAVEN_HOME=/maven/apache-maven-3.5.0
export PATH=$PATH:$MAVEN_HOME/bin

"profile" 85L, 1945C written
[root@model etc]# 
[root@model etc]# 

步骤4:使使修改后的/etc/profile文件生效

[root@model etc]# source /etc/profile

步骤5:验证maven是否安装成功

[root@model etc]# mvn -v
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
Maven home: /maven/apache-maven-3.5.0
Java version: 1.8.0_141, vendor: Oracle Corporation
Java home: /java/jdk1.8.0_141/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix"
[root@model etc]# 

至此,maven安装完成~

posted on 2017-08-01 11:05  简单侠  阅读(227)  评论(0编辑  收藏  举报

导航