1. Environmental description:
OS: Ubuntu 14.04 LTS (64-bit)
maven : apache-maven-3.3.9
2. Download maven
Download link: http://maven.apache.org/download.cgi
Select the latest version of the maven installation package. The latest installation package when I installed it was apache-maven-3.3.9-bin.tar.gz.
The path to download and save the file is: ~/Documents/.
3. Decompression and installation
~$ cd ~/Documents
Unzip:
~/Documents$ tar -zxvf apache-maven-3.3.9-bin.tar.gz
Fourth, set environment variables
Open and edit the profile file as root:
~/下载$ sudo gedit /etc/profile
Add at the end of the file:
#set maven environment
M2_HOME=/home/hetaoo/Documents/Wroks/maven/apache-maven-3.3.9
export MAVEN_OPTS="-Xms256m -Xmx512m"
export PATH=$M2_HOME/bin:$PATH
Save and close.
For the configuration to take effect, you must restart the machine or enter at the command line:
~/下载$ . /etc/profile
Check if maven is installed successfully:
~/下载$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /home/hetaoo/Documents/Wroks/maven/apache-maven-3.3.9
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: /opt/java/jdk1.8.0_91/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.2.0-42-generic", arch: "amd64", family: "unix"
Five, configure the user scope setting.xml
Execute the following statement to automatically generate the .m2 directory:
~/下载$ mvn clean
Copy the /usr/local/apache-maven-3.2.2 /conf/settings.xml file to the ~/.m2 directory:
~/下载$ cp /usr/local/apache-maven-3.2.2/conf/settings.xml ~/.m2/
Modify the ~/.m2/settings.xml file:
~/下载$ gedit ~/.m2/settings.xml
found in the file
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
Add content after it:
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
<localRepository>${user.home}/repository/maven</localRepository>
Where: ${user.home}/repository/maven is the path to your maven local repository.
Save and exit.