Ubuntu 18.04The installationmaven

#The installation
sudo apt install maven
#Configuration setting
Copy the code
#Create maven directory
sudo mkdir /usr/local/maven

#Go to the Maven directory
cd /usr/maven/

#Download mavenSudo wget HTTP: / / https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
#Unpack theSudo tar ZXVF - apache maven - 3.6.3 - bin. Tar. Gz
#Delete the fileSudo rm - rf. / apache maven - 3.6.3 - bin. Tar. Gz
#Edit the file.bashrc
sudo vim ~/.bashrc

#Add to the end of the.bashrc file add:Export M2_HOME=/usr/local/maven/apache-maven-3.6.3 export CLASSPATH=$CLASSPATH:$M2_HOME/lib export PATH=$PATH:$M2_HOME/bin
#Reload resources
source ~/.bashrc

#Check the maven
mvn --version

#Modify maven Settings by copying the setting. XML file as noted below to modify the localRepository locationCD/user/local/maven/apache maven - 3.6.1 track/confCopy the code

      
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/maven/repos</localRepository>
  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
  </servers>

  <mirrors>
    <! -- Company Image library -->
    
    <! -- Aliyun Warehouse -->
    <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>

    <! -- Central Warehouse 1 -->
    <mirror>
      <id>repo1</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://repo1.maven.org/maven2/</url>
    </mirror>

    <! -- Central Warehouse 2 -->
    <mirror>
      <id>repo2</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://repo2.maven.org/maven2/</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>JDK - 1.8 -</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>
  </profiles>
</settings>
Copy the code

mavenCommon operations

#Clear the generated project target
mvn clean

#packaging
mvn package

#Docker packaging
mvn package docker:build

#compile
mvn compile

#Install jar in local repository containing MVN compile, MVN package, then upload to local repository
mvn install
Copy the code