maven配置指南

maven 配置指南

maven安装与下载

配置环境变量

  1. 环境变量设置步骤:
    image
    image

  2. 配置JDK环境变量

  1. MAVEN环境配置
  • maven根目录
    image
  • 配置环境变量
    image
  1. 环境变量里的path配置
  • 进入path编辑页面
    image
  • 将上面的路径+bin文件层级放入path:或使用%JAVA_HOME%\bin来表达
    image
  1. 配置maven仓库配置
  • 寻一处文件目录创建maven仓库文件夹
    image
  • 找到maven的配置文件conf
  • 进入maven根目录->conf文件夹->settings.xml
    image
  • 在setting.xml里配置仓库地址和镜像源
  <!-- 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>D:\tools\repository</localRepository>

  • 找到标签<mirrors></mirrors>在标签里添加以下代码,若找不到可自行添加<mirrors></mirrors>
<!-- 阿里云仓库 -->
<mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

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

<!-- 中央仓库2 -->
<mirror>
    <id>repo2</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>http://repo2.maven.org/maven2/</url>
</mirror>

  1. 配置idea
    file->settings->搜索maven