eclipse 多个 maven pom.xml 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4175380/
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-19 15:20:12  来源:igfitidea点击:

Multiple maven pom.xml files

javaeclipsemavenm2eclipse

提问by christophmccann

I have an Eclipse project with a GWT client and a Restlet API. I normally use Maven for dependency management but I havent used it in an Eclipse project where seperate parts have seperate dependencies. For example - the client would use Google Gin for dependency injection and the server uses Google Guice.

我有一个带有 GWT 客户端和 Restlet API 的 Eclipse 项目。我通常使用 Maven 进行依赖管理,但我还没有在 Eclipse 项目中使用它,其中单独的部分具有单独的依赖关系。例如 - 客户端将使用 Google Gin 进行依赖注入,而服务器使用 Google Guice。

Am I able to split it into two seperate pom.xml files to manage the dependencies of both seperate areas?

我可以将它拆分成两个单独的 pom.xml 文件来管理两个单独区域的依赖关系吗?

Thanks

谢谢

采纳答案by CoolBeans

You can create a multi module project. See examples hereand hereand here.

您可以创建一个多模块项目。请参阅此处此处以及此处的示例。

回答by felipealvesgnu

You could create a new pom like this:

你可以像这样创建一个新的 pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>your-dependencies</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>

    <dependencies>
        ...
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>mailapi</artifactId>
            <version>1.5.0</version>
        </dependency>
        ...
    </dependencies>
</project>

Then in your original project just add:

然后在您的原始项目中添加:

<dependencies>
    <dependency>
        <groupId>com.mycompany</groupId>
        <artifactId>your-dependencies</artifactId>
        <version>1.0.0</version>
        <type>pom</type>
    </dependency>
</dependencies>