简体   繁体   English

pom对3个应用程序使用通用依赖项Spring-mvc

[英]pom use a common dependency for 3 applications Spring-mvc

I have a dependency called "general-lib" which will be modified and used by 3 teams. 我有一个名为“ general-lib”的依赖项,将被3个团队修改和使用。

  • Admin, Child-ABC and Child-XYZ are those 3 projects. Admin,Child-ABC和Child-XYZ是这3个项目。 Those 3 apps deployed in same server. 这3个应用程序部署在同一服务器上。
  • Child-XYZ and Child-ABC are communicating to Admin app frequently. Child-XYZ和Child-ABC经常与Admin应用通信。
  • When we change general-lib version, I want that Child apps also should use same version what admin app uses. 当我们更改通用库版本时,我希望子应用也应使用与管理员应用相同的版本。

Finally that particular dependency version should be managed at super application. 最后,应该在超级应用程序中管理特定的依赖版本。

is there any to do that ? 有什么办法吗? Please let me know if I need to explain better. 如果需要进一步说明,请告诉我。

You can define a BOM ( Bills of Materials ) where you can move the dependecyManagement for the common artifacts and then declare it as a parent in your 3 projects. 您可以定义一个BOM( 物料清单 ),您可以移动dependecyManagement在3个项目为共同的工件,然后把它声明为父母。 This is an example of BOM: 这是BOM的示例:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>your.group.id</groupId>
    <artifactId>whatever-BOM</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <general-lib.version>1.0.2</general-lib.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>your.groupid</groupId>
                <artifactId>general-lib</artifactId>
                <version>${general-lib.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

For more details on BOM , you can read the article Spring with Maven BOM that even if it's related to Spring, it will explain in a detailed way what are BOMs and how to use them. 有关BOM的更多详细信息,您可以阅读文章Spring with Maven BOM ,即使与Spring相关,它也会以详细的方式说明什么是BOM以及如何使用它们。

Ohter possibility, is to define those 3 projects as a module of a higher level project and manage in this one the dependencyManagement . 更有可能的是,将这三个项目定义为一个更高级别的项目的模块,并在这一项目中管理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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>your.group.id</groupId>
    <artifactId>whatever</artifactId>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>Admin</module>
        <module>Child-ABC</module>
        <module>Child-XYZ</module>
    </modules>
    <packaging>pom</packaging>

    <properties>
        <general-lib.version>1.0.2</general-lib.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>your.groupid</groupId>
                <artifactId>general-lib</artifactId>
                <version>${general-lib.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

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

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