IDEA maven installation and set automatic download package configuration

In the process of our development environment if configured Well, for us to develop the optimal significant role in reducing the time can be developed, then I explain maven installation and configuration, and configuration on the idea, while hope this tutorial excellent help everyone.

1.1. Download and install maven

  The latest version is apache-maven-3.5.3 version, we were using apache-maven-3.5.2 version, you can download the latest version. Apache-maven-3.5.2 Download: http: //archive.apache.org/dist/maven/maven-3/ version of the download as follows: 

 1.2.Maven software installed
  after downloading Maven, Maven will not extract to a Chinese path without spaces, such as D: \ software \ maven below. After extracting the directory structure as follows:

bin: to store the maven command, such as we used earlier mvn tomcat: run boot: storing some maven bootstrap itself, such as class loader and other conf: maven store some configuration files, such as file lib setting.xml : Some storage jar package needed to run itself maven maven far our software is ready for use, the premise is already installed and configured on your computer before good JDK

1.3JDK of preparation and unity
  I have unified software tool to use, JDK version 1. JDK use JDK8 environment:

 

2.1. Maven and the JDK configured
to be installed java environment on the computer, install JDK1.7 + version (the JAVA_HOME / bin configuration environment variable path), we are using a version JDK8 related
configuration MAVEN_HOME, the variable value is the path of your maven install ( before a directory bin directory)

上面配置了我们的 Maven 软件,注意这个目录就是之前你解压 maven 的压缩文件包在的的目录,最 好不要有中文和空格。 再次检查 JDK 的安装目录,如下图: 

 2.2Maven 软件版本测试 

  

通过 mvn -v命令检查 maven 是否安装成功,看到 maven 的版本为 3.5.2 及 java 版本为 1.8 即为安装 成功。 找开 cmd 命令,输入 mvn –v命令,如下图:

2.3Maven 仓库 

maven 的工作需要从仓库下载一些 jar 包,如下图所示,本地的项目 A、项目 B 等都会通过 maven 软件从远程仓库(可以理解为互联网上的仓库)下载 jar 包并存在本地仓库,本地仓库 就是本地文 件夹,当第二次需要此 jar 包时则不再从远程仓库下载,因为本地仓库已经存在了,可以将本地仓库 理解为缓存,有了本地仓库就不用每次从远程仓库下载了。 

 本地仓库 :用来存储从远程仓库或中央仓库下载的插件和 jar 包,项目使用一些插件或 jar 包, 优先从本地仓库查找  默认本地仓库位置在 ${user.dir}/.m2/repository,${user.dir}表示windows 用户目录。 

 远程仓库:如果本地需要插件或者 jar 包,本地仓库没有,默认去远程仓库下载。 远程仓库可以在互联网内也可以在局域网内。

 中央仓库 :在 maven 软件中内置一个远程仓库地址 http://repo1.maven.org/maven2 ,它是中 央仓库,服务于整个互联网,它是由 Maven 团队自己维护,里面存储了非常全的 jar 包,它包 含了世界上大部分流行的开源项目构件。

2.4. Maven 本地仓库的配置 

本课程是在无网的状态下学习,需要配置老师提供的本地仓库,将 “repository.rar”解压至自己的 电脑上,我们解压在 D:\repository 目录下(可以放在没有中文及空格的目录下)。 

 在 MAVE_HOME/conf/settings.xml 文件中配置本地仓库位置(maven 的安装目录下): 

 

 打开 settings.xml文件,配置如下

3.1 idea 配置maven

   打开FileSettings 配置 maven 

  依据图片指示,选择本地 maven 安装目录,指定 maven 安装目录下conf文件夹中 settings 配置文件

3.2设置自动下载

2019-07-1711:50:20

作者:深海收破烂

Guess you like

Origin www.cnblogs.com/itboxue/p/11200115.html