1、下载maven
http://maven.apache.org/download.cgi
点击下载,linux下面下载tar.gz包。
![](https://img.haomeiwen.com/i10422058/5633e4e2fa8447c2.png)
2、maven安装与配置
双击maven压缩包,将压缩包移动到文稿/java目录下面统一管理。
![](https://img.haomeiwen.com/i10422058/fcc442f7d0b55bc9.png)
下面配置maven
(1)通过launchpad打开命令行。
(2)切换权限:sudo su。
(3)编辑文件:vi .bash_profile。
(4)按下i,进入编辑模式。
输入下面两行:
export MAVEN_HOME=/Users/用户/Documents/java/maven360/
export PATH=$PATH:$MAVEN_HOME/bin
![](https://img.haomeiwen.com/i10422058/b524a9ee18ffd824.png)
(5) 按esc,输入 :wq退出并保存当前文件。
(6)通过输入 source .bash_profile,按下Enter键使bash_profile生效。
(7) 通过输入 mvn -v,结果如下图所示即表明配置成功。
![](https://img.haomeiwen.com/i10422058/ee25a8b805545703.png)
(8) 配置settings.xml文件。
修改以下配置:
<localRepository>/Users/tangscott/Documents/java/repository</localRepository>
默认的镜像下载速度很慢,我们可以换成阿里云的镜像。
![](https://img.haomeiwen.com/i10422058/6782e4bd9a7f7cd5.png)
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
3、在Eclipse中配置maven插件
(1)选择下面菜单点击。
![](https://img.haomeiwen.com/i10422058/40f3a3d0ddfb580c.png)
(2)通过以下步骤添加maven的路径。
![](https://img.haomeiwen.com/i10422058/bdafe95c11c121ef.png)
(3)选择以下maven目录,选择完成后点击finish。
![](https://img.haomeiwen.com/i10422058/e745fa0c64a19fa6.png)
选择自己安装的maven,apply and close 确定。
![](https://img.haomeiwen.com/i10422058/dd13a7ea043f1e84.png)
(4)双击browse选择安装maven的settings.xml。
![](https://img.haomeiwen.com/i10422058/08e0e5e7d1e67aec.png)
![](https://img.haomeiwen.com/i10422058/671cd49cfdabe0d8.png)
(5)设置完成。
网友评论