You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

含Quarkus与非Quarkus模块的Maven多模块项目如何顺畅运行开发模式?

Quarkus多模块项目依赖非Quarkus模块的高效开发方案

我有一个Maven多模块项目,包含Quarkus模块(module2)和纯Java非Quarkus模块(module1),其中module2依赖module1。进入module2目录执行mvn quarkus:dev启动开发模式时,出现如下错误:

[ERROR] Failed to execute goal on project module2: Could not resolve dependencies for project xxx:module2:jar:1.0: The following artifacts could not be resolved: xxx.root:module1:jar:1.0 (absent): xxx.root:module1:jar:1.0 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced

原因是module1未本地安装且无法从远程仓库拉取,目前必须先对module1和根项目执行mvn clean install才能启动module2的开发模式。但频繁修改module1时重复执行该操作效率极低,求更顺畅的开发方式。

项目结构

root
├── module1 (纯Java非Quarkus项目)
└── module2 (Quarkus项目)

各模块pom.xml配置

根项目pom.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>xxx</groupId>
    <artifactId>root</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <modules>
        <module>module1</module>
        <module>module2</module>
    </modules>
</project>

module1的pom.xml

<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>
    <parent>
        <groupId>xxx</groupId>
        <artifactId>root</artifactId>
        <version>1.0</version>
    </parent>

    <artifactId>module1</artifactId>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>

module2的pom.xml

<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>
    <parent>
        <groupId>xxx</groupId>
        <artifactId>root</artifactId>
        <version>1.0</version>
    </parent>

    <artifactId>module2</artifactId>

    <properties>
        <compiler-plugin.version>3.13.0</compiler-plugin.version>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
        <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
        <quarkus.platform.version>3.17.7</quarkus.platform.version>
        <skipITs>true</skipITs>
        <surefire-plugin.version>3.5.0</surefire-plugin.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.synkronize</groupId>
            <artifactId>commons</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-rest</artifactId>
        </dependency>
    </dependencies>

<!-- ... 省略Quarkus Maven插件配置 ... -->
</project>

已采用的解决方案

为避免频繁执行mvn clean install以及多终端操作,通过IntelliJ的运行配置创建两个Maven运行配置,实现多模块并行开发:

  • 为module1创建Maven运行配置,配置自动编译打包逻辑,确保代码修改后自动更新依赖
  • 为module2创建Maven运行配置,执行mvn quarkus:dev启动开发模式
    两个配置并行运行,module1修改后无需手动执行安装命令,即可自动同步到module2的开发环境中。

内容的提问来源于Stack Exchange,提问作者Matheus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 22:49:56