`
郑云飞
  • 浏览: 795437 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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的环境变量,如下所示:
1 steven@ubuntu:~$ export M2_HOME=/home/steven/tools/apache-maven-3.0.3
2 steven@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
010 HISTCONTROL=ignoredups:ignorespace
011  
012 # append to the history file, don't overwrite it
013 shopt -s histappend
014  
015 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
016 HISTSIZE=1000
017 HISTFILESIZE=2000
018  
019 # check the window size after each command and, if necessary,
020 # update the values of LINES and COLUMNS.
021 shopt -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)
029 fi
030  
031 # set a fancy prompt (non-color, unless we know we "want" color)
032 case "$TERM" in
033     xterm-color) color_prompt=yes;;
034 esac
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
050 fi
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\]\$ '
054 else
055     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
056 fi
057 unset color_prompt force_color_prompt
058  
059 # If this is an xterm set the title to user@host:dir
060 case "$TERM" in
061 xterm*|rxvt*)
062     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
063     ;;
064 *)
065     ;;
066 esac
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'
078 fi
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
096 fi
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
103 fi
104 export PATH=${PATH}:/home/steven/tools/android-sdk-linux_x86/tools
105  
106  
107 export M2_HOME=/home/steven/tools/apache-maven-3.0.3
108 export PATH=$PATH:$M2_HOME/bin
在终端执行"mvn -version",会输出下面的内容,表示安装成功。 
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics