Maven 3.3 要求 JDK 1.7 或以上
Maven 3.2 要求 JDK 1.6 或以上
Maven 3.0/3.1 要求 JDK 1.5 或以上

mkdir /usr/lib/jvm/
tar -xvf jdk-7u55-linux-x64.tar.gz -C /usr/lib/jvm/
echo "export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_55" >>  /etc/profile
source /etc/profile
echo "export JRE_HOME=${JAVA_HOME}/jre" >>  /etc/profile
source /etc/profile
echo "export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" >>  /etc/profile
echo "export PATH=${JAVA_HOME}/bin:$PATH" >>  /etc/profile
source /etc/profile
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_55/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_55/bin/javac 300

进入Apache maven官网:,然后点击Download进入下载界面,或者直接进入下载界面:,这里下载最新版本的apache-maven-3.5.2的二进制包,

tar -xvzf apache-maven-3.5.2-bin.tar.gz
mv apache-maven-3.5.2 /usr/local/maven




source /etc/profile


mvn -v

mvn clean 会把原来target目录给删掉重新生成。
mvn install 安装当前工程的输出文件到本地仓库,打war包
mvn clean install 先删除target文件夹,在打war包

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns=""
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   | Default: ${user.home}/.m2/repository

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   | Default: true

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   | Default: false

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.

    <!-- Another sample, using keys to authenticate.
      <passphrase>optional; leave empty if not used.</passphrase>



带符号 * 的表示必填项