单个还是多个Maven pom.xml配置文件? [英] Single or Multiple Maven pom.xml configuration files?

查看:1060
本文介绍了单个还是多个Maven pom.xml配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下与Maven项目中的pom.xml文件有关的这些问题。

I would like to ask these questions related to pom.xml files in Maven projects.


  • 有多个<的理由是什么?所有依赖库的code> pom.xml 而不是所有依赖项都在一个 pom.xml

  • Maven项目中的这些 pom.xml 文件应放在哪里?

  • What is a reason to have multiple pom.xml for all dependency libraries instead of having all dependencies in one single pom.xml?
  • Where should be these pom.xml files in Maven project placed?

这是Spring框架的pom.xml示例 - http://search.maven.org/remotecontent?filepath=org/springframework/spring-core/3.2.5.RELEASE/spring-core-3.2.5.RELEASE。 pom

This is an example of pom.xml for Spring framework - http://search.maven.org/remotecontent?filepath=org/springframework/spring-core/3.2.5.RELEASE/spring-core-3.2.5.RELEASE.pom

推荐答案



  • 有什么理由要有所有依赖库的多个pom.xml而不是所有依赖项都在一个pom.xml中?

maven项目可以由很多人组成rtifacts。一个工件可能是String操作库。另一个可能是使用该String操作库的webapp。

A maven project can be made of many artifacts. One artifact may be a String manipulation library. Another may be a webapp that uses that String manipulation library.

这就是为什么你不应该将所有依赖项放在一个pom中:你的String操作库不应该只引用servlets.jar,因为一个不相关的pom是一个Web应用程序。 每个工件应该只在其类路径中具有所需的

Here's why you shouldn't put all your dependencies in one pom: Your String manipulation library should not have a reference to the servlets.jar just because an unrelated pom is a webapp. Each artifact should have only what it needs in its classpath.

(您可能有兴趣了解 dependencyManagement 标记,但它与您的问题没有直接关系。)

(You may be interested to learn about the dependencyManagement tag, but it does not directly relate to your question.)



  • Maven项目中的这些pom.xml文件应放在哪里?

当@MariuszS链接到时,这里是标准目录布局

As @MariuszS linked to, here's the Standard Directory Layout.


顶级文件描述项目: pom.xml文件(以及使用Ant时的任何属性,maven.xml或build.xml)。此外,还有一些文本文档供用户在接收源时立即阅读:README.txt,LICENSE.txt等。

At the top level files descriptive of the project: a pom.xml file (and any properties, maven.xml or build.xml if using Ant). In addition, there are textual documents meant for the user to be able to read immediately on receiving the source: README.txt, LICENSE.txt, etc.

这篇关于单个还是多个Maven pom.xml配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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