将属性传递给 maven 子模块,该子模块没有当前模块作为父模块

Igo*_*gor 6 java maven spring-boot

我有几个 Maven 项目:

  • commons-lib(简单的 Java 项目
  • 用户服务(Spring-Boot 驱动的项目
  • 复合服务(Spring-Boot 驱动的项目
  • 前端服务(Spring-Boot-/Angular2 驱动的项目
  • all-services-parent(构建其他所有内容的父项目

虽然commons-lib不太可能单独发布,但所有其他项目(父项目除外)可能会单独发布。

如果列表中的前四个是第五个的子模块,作为回报,它们是否必须将其父模块设置为父模块(例如 all-services-parent)?

因为我想在用户和复合服务中包含commons-lib,所以我知道我必须先构建它。但是:上述每项服务都可能单独发布 - 那么哪种建筑结构最适合我的需要?

可不可能是:

-- all-services-parent
   |-- (maven sub-module) commons-lib
   |-- (maven sub-module) user-service
   |-- (maven sub-module) composite-service
   |-- (maven sub-module) frontend-service
Run Code Online (Sandbox Code Playgroud)

或者:

-- all-services-parent
   |-- user-service-parent
       |-- (maven sub-module) commons-lib
       |-- (maven sub-module) user-service
   |-- composite-service-parent
       |-- (maven sub-module) commons-lib
       |-- (maven sub-module) composite-service
   |-- frontend-service
Run Code Online (Sandbox Code Playgroud)

第二个构建结构将允许我通过在所有服务父级上调用“mvn clean install”来构建所有 JAR,同时仍然能够通过在相应的父级上调用“mvn clean install”来正确构建单独的项目,但这真的是它是怎么做的?

在我当前的设置中,我尝试使用第一个构建结构,但是由于例如复合服务将“spring-boot-starter-parent”设置为其父级,因此我无法访问“all-services-parent”中的属性或任何内容“-模块。

我阅读了Maven parent pom vs modules pom(这个问题起初看起来很有希望),但它并没有像我希望的那样适用于我的情况。

Sán*_*hos 3

尝试导入 spring boot 父级而不是像这样继承它:

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.5.9.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
       </dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)