1.下載Maven tar.gz包
http://maven.apache.org/download.cgi
2.解壓tar包
隨便一個路徑都行
3.配置環境變量
- bash設置~/.bash_profile
- zsh設置~/.zshrc
以bash設置為例:
Terminal進入用戶根路徑
cd ~
vim 新建文件
vim .bash_profile
修改
MAVEN_HOME=/Users/maven/apache-maven-3.2.1 PATH=$PATH:$MAVEN_HOME/bin
export MAVEN_HOME export PATH
4.讀取配置文件
source .bash_profile
5.查看Maven配置是否成功
mvn -v
6.新建本地Repository
創建一個文件夾名為repository,找到Maven安裝路徑下conf/setting.xml
在文件中<settings>后加入
<localRepository>/剛剛創建文件夾的路徑/repository</localRepository>
7.Eclipse配置Maven
進入Preference -> maven -> installation ->Add 選擇Maven的安裝路徑
之后,進入User Setting 設置setting.xml文件路徑
選擇conf/setting.xml文件
