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

Quarkus升级至最新版本时无法定位CDIProvider问题求助

解决Quarkus升级后Unable to locate CDIProvider报错问题

从你的报错堆栈和POM文件来看,问题的核心是依赖版本不统一以及部分不必要的依赖引入,导致CDI容器初始化失败。以下是具体的修复步骤:

1. 统一所有Quarkus组件的版本

你已经通过quarkus-bom导入了版本管理,所以所有Quarkus相关依赖都不需要手动指定version属性,BOM会自动统一版本。需要修改这些依赖:

  • 将quarkus-smallrye-rest-client的版本移除,让BOM管理:
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-smallrye-rest-client</artifactId>
</dependency>
  • 删除quarkus-arc-deployment依赖,这个是部署阶段的专属依赖,正常运行不需要,而且BOM已经包含了对应的运行时依赖quarkus-arc:
<!-- 移除这个不匹配版本的依赖 -->
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-arc-deployment</artifactId>
    <version>0.20.0</version>
</dependency>

2. 移除重复的MicroProfile依赖

quarkus-smallrye-health已经内置了microprofile-health-api,手动添加的这个依赖会造成版本冲突,直接删除即可:

<!-- 移除这个重复依赖 -->
<dependency>
    <groupId>org.eclipse.microprofile.health</groupId>
    <artifactId>microprofile-health-api</artifactId>
    <version>${microprofile.version}</version>
</dependency>

3. 清理并重新构建项目

  • 确保你添加的beans.xml放在src/main/resources/META-INF/目录下,最简内容如下即可:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
       version="2.0" bean-discovery-mode="all">
</beans>
  • 执行mvn clean install清理旧依赖缓存,重新构建项目。

问题根源说明

Quarkus的组件高度耦合,版本不一致会引发类加载冲突,尤其是CDI核心组件(比如Arc)。当quarkus-arc和quarkus-arc-deployment版本不匹配时,CDI容器无法正确初始化,就会抛出Unable to locate CDIProvider的错误。同时,重复引入API依赖也可能干扰容器的正常启动流程。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:26:06