java - 单个或多个 Maven pom.xml 配置文件?

标签 java xml maven pom.xml

请教Maven项目中pom.xml文件相关问题

  • 为什么要为所有依赖库使用多个 pom.xml 而不是将所有依赖项都放在一个 pom.xml 中?
  • Maven项目中的pom.xml文件应该放在哪里?

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

最佳答案

  • What is a reason to have multiple pom.xml for all dependency libraries instead of having all dependencies in one single pom.xml?

一个 Maven 项目可以由许多 Artifact 组成。一个 Artifact 可能是一个字符串操作库。另一个可能是使用该字符串操作库的网络应用程序。

这就是您不应该将所有依赖项放在一个 pom 中的原因:您的字符串操作库不应该仅仅因为一个不相关的 pom 是一个 webapp 而引用 servlets.jar。 每个 Artifact 都应该在其类路径中只包含它需要的内容。

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

  • Where should be these pom.xml files in Maven project placed?

作为@MariuszS 的链接,这里是the Standard Directory Layout .

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.

关于java - 单个或多个 Maven pom.xml 配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20010009/

相关文章:

javascript - 通过 javascript 从 XML 中检索值

java - 为什么 SwitchCompat 不能在 Android Studio 上运行?

java - 找到多个定义...我有 2 个类似的定义

Java main() 方法未完全运行 - 从同一应用程序运行客户端和服务器

c# - 在调用 Read() 之前如何检查 XmlReader 是否可以读取内容?

java - 每个 JVM 或每个 CPU 核心的线程数

maven - 部署部署两次或根本不部署

java - testng 报告中的“报告器输出”为空

java - 计费系统中的多线程

java - JsonView 无法与 Spring 一起正常工作