前言:本文将从新手的角度一步一步简单易懂的阐述相应的内容
第一步:获取Maven资源
官方下载:
注意:页面中的System Requirements着重关注一点,目前的3.3版本都需要JDK1.7
以上的版本
第二步:解压相应的版本
Windows用户: 直接用
Linux/Mac用户:RAR
工具或者ZIP
工具解压相应目录即可tar -zxvf apache-maven-3.3.y.tar.gz
命令解压即可
第三步:阅读${maven}\README.txt
文件,截取关键地方并已备上注释(提示:英文不佳,可通过有道词典
辅助翻译)
Apache Maven What is it? ----------- //介绍Maven是一个依托POM布局概念管理项目的编译、发布以及文档的工具 Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. //系统要求,必看,包括JDK版本、内存、硬盘大小、操作系统 System Requirements ------------------- JDK: 1.7 or above (this is to execute Maven - it still allows you to build against 1.3 and prior JDK's). Memory: No minimum requirement. Disk: Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB. Operating System: Windows: Windows 2000 or above. Unix based systems (Linux, Solaris and Mac OS X) and others: No minimum requirement. //如何安装Maven Installing Maven ---------------- 1) Unpack the archive where you would like to store the binaries, eg: Unix-based operating systems (Linux, Solaris and Mac OS X) tar zxvf apache-maven-3.x.y.tar.gz Windows unzip apache-maven-3.x.y.zip 2) A directory called "apache-maven-3.x.y" will be created. //如何设置Maven环境 3) Add the bin directory to your PATH, eg: Unix-based operating systems (Linux, Solaris and Mac OS X) export PATH=/usr/local/apache-maven-3.x.y/bin:$PATH Windows set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH% //JDK环境必须已在Path环境中,方可让Maven跑动起来 4) Make sure JAVA_HOME is set to the location of your JDK //通过 mvn --version来检查mvn是否正确安装 5) Run "mvn --version" to verify that it is correctly installed.
第四步:对上述README.txt
文本中的Linux/Mac系统maven环境设置作下补充:
- 打开~/.bash_profile环境变量配置文件
vi ~/.bash_profile
- 导入
JAVA_HOME
和Maven环境
#导入JAVA环境 export JAVA_HOME= /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home #导入MAVEN环境export M2_HOME=/Users/jtj/workroom/mavenroom/apache-maven-3.3.9export PATH=$PATH:$M2_HOME/bin
第五步:测试Maven安装是否成功出现以下结果即成功
jtjdeMacBook-Pro:~ jtj$ mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)Maven home: /Users/jtj/workroom/mavenroom/apache-maven-3.3.9Java version: 1.7.0_79, vendor: Oracle CorporationJava home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jreDefault locale: zh_CN, platform encoding: UTF-8OS name: "mac os x", version: "10.11.4", arch: "x86_64", family: "mac"