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

运行OpenLiberty mpRestClient教程示例报feature definition未找到错误

问题原因

你使用的是OpenLiberty 21.0.0.9的最小内核版本(openliberty-kernel),该版本仅包含最基础的运行时核心,不会内置项目server.xml中配置的cdi-2.0、mprestclient-2.0这类Java EE/MicroProfile特性包,启动时无法找到对应的特性定义就会抛出CWWKF0001E错误。

解决方法

你可以选择以下任意一种方案处理:

  • 方案1:替换依赖为完整版本的OpenLiberty
    修改项目pom.xml中的openliberty依赖配置,把openliberty-kernel替换为openliberty-runtime或者openliberty-microprofile4,后者已内置所有MicroProfile 4相关特性,刚好匹配你用到的mpconfig-2.0、mprestclient-2.0的版本要求。
    参考依赖配置:
    <dependency>
        <groupId>io.openliberty</groupId>
        <artifactId>openliberty-microprofile4</artifactId>
        <version>21.0.0.9</version>
        <type>zip</type>
    </dependency>
    
  • 方案2:开启Liberty Maven插件的自动特性下载功能
    在pom.xml的liberty-maven-plugin配置段中添加自动下载开关,插件会在启动前自动拉取server.xml里配置的所有缺失特性:
    <plugin>
        <groupId>io.openliberty.tools</groupId>
        <artifactId>liberty-maven-plugin</artifactId>
        <version>3.7.1</version>
        <configuration>
            <features>
                <acceptAutomaticFeature>true</acceptAutomaticFeature>
            </features>
        </configuration>
    </plugin>
    
  • 方案3:升级OpenLiberty到更新的稳定版
    21.0.0.9是2021年发布的旧版本,如果你没有强制版本要求,可以直接把OpenLiberty版本升级到23.0.0.1之后的稳定版,新版的特性匹配和自动拉取逻辑更完善,也能避免旧版本的兼容问题。

所有方案操作完成后,执行mvn clean清理之前的目标目录缓存,再重新执行mvn liberty:run启动即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.04 22:18:03