Maven安装和配置

下载Maven

Maven – Download Apache Maven

配置环境变量

Windows下配置环境变量即可,Ubuntu下在~/.bashrc里加入如下两行语句即可。

export M2_HOME=/home/alan/Documents/Applications/apache-maven-3.5.0
export PATH=$M2_HOME/bin:$PATH

在命令行运行mvn -v,若显示Maven版本信息则说明环境变量配置成功。

配置settings.xml

打开用户目录下的~/.m2/settings.xml(没有的话从安装目录的conf文件夹下复制一个过来)。

配置本地仓库地址

/home/alan/Documents/Frameworks/Maven-repository

配置Maven国内镜像


  alimaven
  aliyun maven
  http://maven.aliyun.com/nexus/content/groups/public/
  central


  central
  Maven Repository Switchboard
  http://repo1.maven.org/maven2/
  central


  repo2
  central
  Human Readable Name for this Mirror.
  http://repo2.maven.org/maven2/


  ibiblio
  central
  Human Readable Name for this Mirror.
  http://mirrors.ibiblio.org/pub/mirrors/maven2/


  jboss-public-repository-group
  central
  JBoss Public Repository Group
  http://repository.jboss.org/nexus/content/groups/public



  maven.net.cn
  oneof the central mirrors in china
  http://maven.net.cn/content/groups/public/
  central

你可能感兴趣的:(Maven安装和配置)