原因:java.lang.ClassNotFoundException:找不到 jakarta.ws.rs.client.ClientBuilder 的提供程序

问题描述 投票:0回答:1

我正在将我的项目从 Java EE 7 迁移到 Jakarta EE 10.0.0,并更改了所有与 jakarta 相关的 javax 引用。

我没有任何编译问题,但在运行时出现以下错误。

原因:java.lang.ClassNotFoundException:找不到 jakarta.ws.rs.client.ClientBuilder 的提供程序。

以下是我在项目中使用的依赖项。我添加了 jersey-client 和 jersey-media-json-jackson 来修复 ClientBuilder 问题。

我已经实现了我的 ClientBuilder,如下所示

CLIENT = ClientBuilder.newBuilder().register(JacksonFeature.class).build();
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>3.2.2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>2.16.1</version>
            </dependency>
            <dependency>
                <groupId>jakarta.platform</groupId>
                <artifactId>jakarta.jakartaee-api</artifactId>
                <version>10.0.0</version>
            </dependency>
            <dependency>
                <groupId>jakarta.xml.bind</groupId>
                <artifactId>jakarta.xml.bind-api</artifactId>
                <version>4.0.1</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.core</groupId>
                <artifactId>jersey-client</artifactId>
                <version>3.1.5</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-json-jackson</artifactId>
                <version>3.1.5</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.12</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.17.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.17.1</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.microprofile.config</groupId>
                <artifactId>microprofile-config-api</artifactId>
                <version>3.1</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.oracle.ojdbc</groupId>
                <artifactId>ojdbc10</artifactId>
                <version>19.20.0.0</version>
            </dependency>
jersey jax-rs jersey-client
1个回答
0
投票

我能够通过添加以下依赖项并将客户端生成器实现更改为

来解决该问题

CLIENT = JerseyClientBuilder.newClient();

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>3.1.5</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
            <version>3.1.5</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-binding</artifactId>
            <version>3.1.5</version>
        </dependency>
© www.soinside.com 2019 - 2024. All rights reserved.