如何在多模块项目中使用maven生成jar

问题描述

我有一个具有以下设置的多模块项目: 模块 A 在其 pom.xml 中有一个 Helper 模块作为依赖项

    <dependency>
        <groupId>org.example</groupId>
        <artifactId>Helper</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>

Helper 模块也有一个依赖项:

    <dependency>
        <groupId>org.example</groupId>
        <artifactId>Another helper</artifactId>
        <version>1.0-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>

如何使用 Spring Boot Maven 插件生成模块 A 的可执行 Jar

解决方法

如果您使用的是 IntelliJ(我认为您正在使用),那么您的 pom.xml 应该包含在您的模块中,然后您可以像往常一样构建它。

在 IntelliJ 中,您有两种可能的选项来使用 maven 生成可执行的 .jar,已在 this question 中显示