更新到最新版本时,Quarkus 无法找到 CDIProvider

Quarkus unable to locate CDIProvider when updating to latest version

我目前使用的是 Quarkus 0.22.0 版,我正在尝试将其更新到最新版本,但出现此错误。我还没有找到解决方案,想知道是否有人可以提供帮助。

Caused by: java.lang.RuntimeException: Failed to start quarkus Caused by: java.util.concurrent.CompletionException: java.lang.RuntimeException: RESTEASY003325: Failed to construct public io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature() Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature() Caused by: java.lang.IllegalStateException: Unable to locate CDIProvider

我尝试添加 META-INF/beans.xml 文件并使用 Janex 插件,但没有成功。

POM 文件

<?xml version="1.0"?>

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <surefire-plugin.version>2.22.0</surefire-plugin.version>
    <maven.compiler.target>1.8</maven.compiler.target>
    <quarkus.version>0.27.0</quarkus.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <restClient.version>0.18.0</restClient.version>
    <jedis.version>3.1.0</jedis.version>
    <squirrel.version>0.3.8</squirrel.version>
    <restAssured.version>4.1.2</restAssured.version>
    <testContainers.version>1.12.2</testContainers.version>
    <lombok.version>1.18.10</lombok.version>
    <jetty.version>9.4.19.v20190610</jetty.version>
    <wiremock.version>2.25.1</wiremock.version>
    <redisson.version>3.11.4</redisson.version>
    <microprofile.version>2.1</microprofile.version>
    <license.year>2019</license.year>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-bom</artifactId>
        <version>${quarkus.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>

    <!-- TestContainers -->
      <groupId>org.testcontainers</groupId>
      <artifactId>testcontainers</artifactId>
      <version>${testContainers.version}</version>
    </dependency>

    <!-- Rest client -->
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-rest-client</artifactId>
      <version>${restClient.version}</version>
    </dependency>

    <!-- Quarkus -->
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-arc-deployment</artifactId>
        <version>0.20.0</version>
    </dependency>
    <dependency>
        <groupId>io.quarkus.arc</groupId>
        <artifactId>arc</artifactId>
        <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy</artifactId>
      <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-jsonb</artifactId>
      <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-health</artifactId>
      <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-junit5</artifactId>
      <version>${quarkus.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-openapi</artifactId>
      <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-validator</artifactId>
      <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-vertx</artifactId>
      <version>${quarkus.version}</version>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-smallrye-opentracing</artifactId>
      <version>${quarkus.version}</version>
    </dependency>

    <!-- Jetty -->
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlets</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-servlet</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-webapp</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${jetty.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- WireMock -->
    <dependency>
      <groupId>com.github.tomakehurst</groupId>
      <artifactId>wiremock</artifactId>
      <version>${wiremock.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- RestAssured -->
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>${restAssured.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>xml-path</artifactId>
      <version>${restAssured.version}</version>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>json-path</artifactId>
      <version>${restAssured.version}</version>
    </dependency>

    <!-- Redis -->
    <dependency>
      <groupId>redis.clients</groupId>
      <artifactId>jedis</artifactId>
      <version>${jedis.version}</version>
    </dependency>
    <dependency>
      <groupId>org.redisson</groupId>
      <artifactId>redisson</artifactId>
      <version>${redisson.version}</version>
    </dependency>

    <!-- Squirrel -->
    <dependency>
      <groupId>org.squirrelframework</groupId>
      <artifactId>squirrel-foundation</artifactId>
      <version>${squirrel.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>slf4j-log4j12</artifactId>
          <groupId>org.slf4j</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Lombok -->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
    </dependency>

<!-- Microprofile health -->
    <dependency>
      <groupId>org.eclipse.microprofile.health</groupId>
      <artifactId>microprofile-health-api</artifactId>
      <version>${microprofile.version}</version>
    </dependency>


  </dependencies>
  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
      </releases>
      </repository>
  </repositories>
  <build>
    <plugins>
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <header>src/main/resources/META-INF/resources/license.txt</header>
          <properties>
            <owner>${organization.name}</owner>
            <project.inceptionYear>${license.year}</project.inceptionYear>
          </properties>
            <excludes>
            <exclude>.mvn/wrapper/MavenWrapperDownloader.java</exclude>
            <exclude>.mvn/wrapper/maven-wrapper.properties</exclude>
            <exclude>infra/api/openapi.yaml</exclude>
            <exclude>infra/temp/openapi.yaml</exclude>
            <exclude>mvnw.cmd</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
        <version>${quarkus.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>build</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <systemProperties>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
          </systemProperties>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.4</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native</id>
      <activation>
        <property>
          <name>native</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-maven-plugin</artifactId>
            <version>${quarkus.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>native-image</goal>
                </goals>
                <configuration>
                  <enableHttpUrlHandler>true</enableHttpUrlHandler>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${surefire-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
                <configuration>
                  <systemProperties>
                    <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                  </systemProperties>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

您混合使用了不同版本的 Quarkus 扩展。那绝对不行:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-arc-deployment</artifactId>
    <version>0.20.0</version>
</dependency>

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-smallrye-rest-client</artifactId>
  <version>${restClient.version}</version>
</dependency>

您已导入 BOM,因此只需删除所有版本。

此外:

  • 你不应该依赖 -deployment 工件,你必须依赖运行时工件,所以它应该是 quarkus-arc 而不是 quarkus-arc-deployemnt
  • quarkus-smallrye-rest-client 已替换为 quarkus-rest-client
  • 不包含 microprofile-health-api,只使用 quarkus-smallrye-health

这是我可以通过快速扫描找到的错误,但这应该可以帮助您朝着正确的方向取得进展。