简体   繁体   English

多个maven pom.xml文件

[英]Multiple maven pom.xml files

I have an Eclipse project with a GWT client and a Restlet API. 我有一个带有GWT客户端和Restlet API的Eclipse项目。 I normally use Maven for dependency management but I havent used it in an Eclipse project where seperate parts have seperate dependencies. 我通常使用Maven进行依赖项管理,但我没有在Eclipse项目中使用它,其中单独的部分具有单独的依赖项。 For example - the client would use Google Gin for dependency injection and the server uses Google Guice. 例如,客户端将使用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 谢谢

You can create a multi module project. 您可以创建一个多模块项目。 See examples here and here and here . 请参阅此处以及此处此处的示例。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM