Maven recipe #0

问题: 多个root pom的dependencyManagement有重复的内容,希望统一管理。
解决:
新建一个空pom.xml,在dependencyManagement中指定这些依赖,如

<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>info.sunng</groupId>
    <artifactId>root</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <dependencyManagement>

        <dependencies>
            <dependency>
                <groupId>info.sunng</groupId>
                <artifactId>X</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

</project>

将这个pom.xml部署到你的Maven私服。

在其他root pom中添加这样的dependencyManagement

....
            <dependency>
                <groupId>info.sunng</groupId>
                <artifactId>root</artifactId>
                <version>0.0.1-SNAPSHOT</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
....

3 thoughts on “Maven recipe #0

  1. Pingback: Here comes the Sun » LM Tooling, 2010

  2. Pingback: Juven Xu » InfoQ Maven专栏(三)——多模块项目的POM重构 UNITED STATES

  3. Pingback: Maven实战(三)——多模块项目的POM重构 | 探微·智在未来 WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>