请教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/