mvn 安装在 maven 中到底做了什么 [英] What does mvn install in maven exactly do

查看:32
本文介绍了mvn 安装在 maven 中到底做了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用 Maven,有人告诉我在特定目录中执行 mvn install.

I just started using Maven and I was told to do mvn install in a specific directory.

mvn install 究竟做了什么?

我认为它会在当前文件夹中查找 pom.xml 并按照该文件中指定的说明开始.对吗?

I think it looks for pom.xml in the current folder and starts following the instructions specified in that file. Is that correct?

推荐答案

您可能已经知道,Maven 是 Apache 提供的构建自动化工具,它的作用不仅仅是依赖管理.我们可以使它成为 Ant 和 Makefile 的对等体,后者会下载所需的所有依赖项.

As you might be aware of, Maven is a build automation tool provided by Apache which does more than dependency management. We can make it as a peer of Ant and Makefile which downloads all of the dependencies required.

mvn install 上,它根据项目配置 pom.xml 在超级 pom.xml<下的所有子项目上构建一个依赖树/code>(根 POM)并在用户文件夹下名为 .m2 的目录中下载/编译所有需要的组件.必须解决这些依赖项,才能在没有任何错误的情况下构建项目,而 mvn install 是一种可以下载大部分依赖项的实用程序.

On a mvn install, it frames a dependency tree based on the project configuration pom.xml on all the sub projects under the super pom.xml (the root POM) and downloads/compiles all the needed components in a directory called .m2 under the user's folder. These dependencies will have to be resolved for the project to be built without any errors, and mvn install is one utility that could download most of the dependencies.

此外,Maven 中还有其他实用程序,例如 dependency:resolve,它们可以在任何特定情况下单独使用.mvn 的构建生命周期如下: 生命周期绑定

Further, there are other utils within Maven like dependency:resolve which can be used separately in any specific cases. The build life cycle of the mvn is as below: LifeCycle Bindings

  1. 流程资源
  2. 编译
  3. process-test-resources
  4. 测试编译
  5. 测试
  6. 安装
  7. 部署

使用标志-DskipTests=true可以忽略这个mvn的测试阶段.

The test phase of this mvn can be ignored by using a flag -DskipTests=true.

这篇关于mvn 安装在 maven 中到底做了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆