linux下安装maven

linux maven3的安装 

1.安装maven之前,要先安装jdk及配置JAVA_HOME环境变量。
 
2.下载maven3,最新版本是Maven3.0.3 ,下载地址:http://maven.apache.org/download.html
下载apache-maven-3.0.3-bin.tar.gz文件后,并解压到/home/steven/tools/apache-maven-3.0.3
 
3.配置maven3的环境变量,先配置M2_HOME的环境变量,如下所示:
1steven@ubuntu:~$ export M2_HOME=/home/steven/tools/apache-maven-3.0.3
2steven@ubuntu:~$ export PATH=$PATH:$M2_HOME/bin
 
4.接着,再把这两条命令加入到系统的登录shell脚本中去,这样,每次启动一个终端,这些配置就能自动执行。以ubuntu为例,编辑~/.bashrc文件,编辑后的内容如下: 
001# ~/.bashrc: executed by bash(1) for non-login shells.
002# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
003# for examples
004 
005# If not running interactively, don't do anything
006 [ -z "$PS1" ] && return
007 
008# don't put duplicate lines in the history. See bash(1) for more options
009# ... or force ignoredups and ignorespace
010HISTCONTROL=ignoredups:ignorespace
011 
012# append to the history file, don't overwrite it
013shopt -s histappend
014 
015# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
016HISTSIZE=1000
017HISTFILESIZE=2000
018 
019# check the window size after each command and, if necessary,
020# update the values of LINES and COLUMNS.
021shopt -s checkwinsize
022 
023# make less more friendly for non-text input files, see lesspipe(1)
024 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
025 
026# set variable identifying the chroot you work in (used in the prompt below)
027 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
028     debian_chroot=$(cat /etc/debian_chroot)
029fi
030 
031# set a fancy prompt (non-color, unless we know we "want" color)
032 case "$TERM" in
033     xterm-color) color_prompt=yes;;
034esac
035 
036# uncomment for a colored prompt, if the terminal has the capability; turned
037# off by default to not distract the user: the focus in a terminal window
038# should be on the output of commands, not on the prompt
039#force_color_prompt=yes
040 
041 if [ -n "$force_color_prompt" ]; then
042     if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
043     # We have color support; assume it's compliant with Ecma-48
044     # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
045     # a case would tend to support setf rather than setaf.)
046     color_prompt=yes
047     else
048     color_prompt=
049     fi
050fi
051 
052 if "$color_prompt" = yes ]; then
053     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
054else
055     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
056fi
057unset color_prompt force_color_prompt
058 
059# If this is an xterm set the title to user@host:dir
060 case "$TERM" in
061xterm*|rxvt*)
062     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
063     ;;
064*)
065     ;;
066esac
067 
068# enable color support of ls and also add handy aliases
069 if [ -x /usr/bin/dircolors ]; then
070     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
071     alias ls='ls --color=auto'
072     #alias dir='dir --color=auto'
073     #alias vdir='vdir --color=auto'
074 
075     alias grep='grep --color=auto'
076     alias fgrep='fgrep --color=auto'
077     alias egrep='egrep --color=auto'
078fi
079 
080# some more ls aliases
081 alias ll='ls -alF'
082 alias la='ls -A'
083 alias l='ls -CF'
084 
085# Add an "alert" alias for long running commands.  Use like so:
086#   sleep 10; alert
087 alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
088 
089# Alias definitions.
090# You may want to put all your additions into a separate file like
091# ~/.bash_aliases, instead of adding them here directly.
092# See /usr/share/doc/bash-doc/examples in the bash-doc package.
093 
094 if [ -f ~/.bash_aliases ]; then
095     . ~/.bash_aliases
096fi
097 
098# enable programmable completion features (you don't need to enable
099# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
100# sources /etc/bash.bashrc).
101 if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
102     . /etc/bash_completion
103fi
104export PATH=${PATH}:/home/steven/tools/android-sdk-linux_x86/tools
105 
106 
107export M2_HOME=/home/steven/tools/apache-maven-3.0.3
108export PATH=$PATH:$M2_HOME/bin
在终端执行"mvn -version",会输出下面的内容,表示安装成功。 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值