eclipse Maven中pom.xml有什么用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14725316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:32:42  来源:igfitidea点击:

What is the use of pom.xml in Maven?

eclipsemavenmaven-plugin

提问by Hazel_arun

I have just started working with Maven in Eclipse.

我刚刚开始在 Eclipse 中使用 Maven。

I tried running a sample program in it, and I encountered some problems. The errors were in my pom.xml file. What is the significance of the pom.xml file in Maven?

我尝试在其中运行示例程序,但遇到了一些问题。错误在我的 pom.xml 文件中。Maven中pom.xml文件的意义是什么?

回答by basiljames

In short the pom.xmlwill have all information to build your project.

简而言之,pom.xml它将拥有构建项目的所有信息。

For example you want to build a project and you have only the pom.xmlsent to you via mail. If there are enough entries in the pom.xmlthen that is all you need! You can import it to Eclipse, Maven will download your source code from CVS, download various dependency jars (like Spring, Apache Commons), run your test cases, build the jar/war, deploy to your jboss/app server, generate a report of your code quality (using Sonar, maybe). Each task you want to do will be mentioned as a goal.

例如,您要构建一个项目,而您只有pom.xml通过邮件发送给您的项目。如果有足够的条目,pom.xml那么这就是您所需要的!您可以将其导入 Eclipse,Maven 将从 CVS 下载您的源代码,下载各种依赖 jar(如 Spring、Apache Commons),运行您的测试用例,构建 jar/war,部署到您的 jboss/app 服务器,生成报告您的代码质量(可能使用声纳)。您想要执行的每项任务都将作为goal.

The links already provided are good enough for reference.

已经提供的链接足以供参考。

回答by Mayur Gupta

POM is an XML file which contains the project configuration details used by Maven. It provides all the configuration required for a project.

POM 是一个 XML 文件,其中包含 Maven 使用的项目配置详细信息。它提供了项目所需的所有配置。

POM means project object model, and, as the name suggests, it defines the model of the project as well.

POM 的意思是项目对象模型,顾名思义,它也定义了项目的模型。

In the normal project development you will add JAR files and libraries as required. In Maven-based development, those JAR files, libraries are added to the project using this pom.xml. In the pomcontext we call those JAR files, libraries as dependencies.

在正常的项目开发中,您将根据需要添加 JAR 文件和库。在基于Maven的开发中,使用这个pom.xml将那些 JAR 文件、库添加到项目中。在pom上下文中,我们将这些 JAR 文件和库称为依赖项

回答by NPKR

Maven is a build tool and pom.xmlis the main file for the project.

Maven 是一个构建工具,pom.xml是项目的主要文件。

The POM

聚甲醛

The pom.xmlfile is the core of a project's configuration in Maven. It is a single configuration file that contains the majority of the information required to build a project in just the way you want. The POM is huge and can be daunting in its complexity, but it is not necessary to understand all of the intricacies just yet to use it effectively.

pom.xml文件是 Maven 中项目配置的核心。它是一个单一的配置文件,包含以您想要的方式构建项目所需的大部分信息。POM 是巨大的,其复杂性可能令人生畏,但为了有效地使用它,还没有必要了解所有的复杂性。

For more reference, check Maven in 5 Minutes.

如需更多参考,请查看Maven in 5 Minutes

回答by user3528426

POM stands for project object model. It's the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used to build the project. It downloads required libraries easily using POM XML tags.

POM 代表项目对象模型。它是 Maven 中的基本工作单元。它是一个 XML 文件,其中包含有关用于构建项目的项目和配置详细信息的信息。它使用 POM XML 标签轻松下载所需的库。

回答by Amitesh Ranjan

pom.xml is a file which describes the project, configures plugins, and declares dependencies. The POM names the project, provides a set of unique identifiers (called coordinates) for a project, and defines the relationships between this project and others through dependencies, parents, and prerequisites.

pom.xml 是一个描述项目、配置插件和声明依赖项的文件。POM 为项目命名,为项目提供一组唯一标识符(称为坐标),并通过依赖项、父项和先决条件定义此项目与其他项目之间的关系。

A POM file can include a modules section, which tells Maven which directories have POM files which need to be built.

POM 文件可以包含一个 modules 部分,它告诉 Maven 哪些目录有需要构建的 POM 文件。

In the build section you can define plugins for which you need to build the artifacts in your project.

在构建部分,您可以定义在项目中构建工件所需的插件。

回答by Ujitha

When there is no Maven, it needs to add all the library JAR files one by one to the project. But when there is Pom.xml there is no need to add library JAR files one by one.

当没有Maven时,需要将所有的库JAR文件一一添加到项目中。但是有Pom.xml的时候就不需要一一添加库JAR文件了。

Simply add the dependency to the Pom.xml, and it will automatically add the library JAR files to the project.

只需将依赖添加到 Pom.xml,它就会自动将库 JAR 文件添加到项目中。