【问题标题】:Multi-module Maven and Spring Boot project doesn´t generate fat executable jar for secondary module多模块 Maven 和 Spring Boot 项目不会为辅助模块生成胖可执行 jar
【发布时间】:2020-12-24 03:57:43
【问题描述】:

我有一个多模块 Maven / Spring Boot (v2.3.3) 应用程序实现如下:

my-project (pom)
  \__ my-api (jar)   - rest api controllers
   \__ my-core (jar) - entities, repositories and service beans
    \__ my-db (jar)  - DB migration (with Mongock)

项目和应用程序运行良好,没什么大不了的。 “my-api” 模块有一个主 Spring Boot 应用程序类,它照常运行 API。

问题是,最近我添加了“my-db”模块来实现 MongoDB 迁移,以便在我的 CI 部署中实现自动化。 “my-db”模块还有另一个主要的spring boot应用程序类,它是一个运行迁移过程的独立应用程序,我想在我的CI环境中自动化。

问题是我的 maven 构建不会为“my-db”模块生成胖可执行 JAR,只为“my-api”模块生成。

我错过了什么吗?

我的项目 pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
    </plugins>
</build>

我的-api pom.xml:

<build>
    <finalName>my-api</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>my.ApiApplication</mainClass>
                <executable>true</executable>
                <layout>JAR</layout>
                <fork>true</fork>
                <skip>false</skip>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我的核心 pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

我的数据库 pom.xml:

<properties>
    <start-class>my.DbMigrationApp</start-class>
</properties>

<build>
    <finalName>my-db</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

【问题讨论】:

    标签: java spring-boot maven


    【解决方案1】:

    “my-db”pom 文件的插件块中似乎缺少此配置。

    <configuration>
        <skip>false</skip>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-27
      • 2015-10-10
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 2016-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多