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

使用Open Liberty 21.0.0.8编译Maven项目microProfile依赖缺失如何解决

问题根因

OpenLiberty 21.0.0.8及之后版本调整了功能类esa依赖的发布规则,io.openliberty.features:microProfile-4.0的pom文件不再预置传递依赖列表,仅作为功能标识文件存在,因此不会自动拉取编译所需的API依赖包,直接导致构建失败。

可行配置调整方案
  • 方案1:使用OpenLiberty官方BOM管理依赖(无Liberty插件场景优先选择)
    在pom.xml的dependencyManagement节点引入OpenLiberty官方物料清单,统一管控所有依赖版本:
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.openliberty.bom</groupId>
            <artifactId>openliberty-runtime</artifactId>
            <version>21.0.0.8</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

再在dependencies节点直接引入MicroProfile全量API依赖,无需额外指定版本号:

<dependency>
    <groupId>org.eclipse.microprofile</groupId>
    <artifactId>microprofile</artifactId>
    <version>4.0</version>
    <type>pom</type>
    <scope>provided</scope>
</dependency>
  • 方案2:保留原esa依赖,通过Liberty插件补全依赖
    如果项目原本使用liberty-maven-plugin管理OpenLiberty运行时,可直接在插件配置中添加feature声明,由插件自动拉取关联依赖:
<plugin>
    <groupId>io.openliberty.tools</groupId>
    <artifactId>liberty-maven-plugin</artifactId>
    <version>3.3.4</version>
    <configuration>
        <featureManager>
            <feature>microProfile-4.0</feature>
        </featureManager>
        <installAppPackages>all</installAppPackages>
    </configuration>
</plugin>

配置完成后执行一次mvn liberty:prepare-feature命令,插件会自动下载该功能对应的全部依赖到本地Maven仓库,后续即可正常编译构建。

验证方式

执行mvn clean compile命令,无类缺失相关的编译报错即为配置生效。

内容的提问来源于stack exchange,提问作者Oliver Webb

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 18:39:01