无法实例化类型 ResteasyClientBuilder。

4

我正在尝试使用代理框架构建一个简单的Resteasy客户端。我遇到了一个错误:"Cannot instantiate the type ResteasyClientBuilder"。这是客户端类。

package com.RestClient.Clients;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;

import com.RestClient.Models.Student;

public class ClientClass {
    ResteasyClient client;
    ResteasyWebTarget base_target,student_target;
    ClientInterface proxy;
    public ClientClass() {
        client = new ResteasyClientBuilder().build();<---------error
        base_target = client.target(UriBuilder.fromPath("http://localhost:8080/demorest/webresources/"));
        student_target = base_target.path("students");
    }
    public int registerStudent(Student s) {
        Response res = proxy.createStudent(s);
        return res.getStatus();
        
    }
}

我在学习这个教程。

1个回答

9

RestEasy Client的版本4.0.0将ResteasyClientBuilder转换为一个抽象类,并提供了你需要的实际实现ResteasyClientBuilderImpl

但是在生成客户端时,你应该使用新的builder

client = ClientBuilder.newBuilder().build();
base_target = client.target("http://localhost:8080/demorest/webresources/");

2
ResteasyClientBuilderImpl 是内部实现细节。请使用 ClientBuilder.newBuilder() 代替(参见 https://docs.jboss.org/resteasy/docs/5.0.1.Final/userguide/html/RESTEasy_Client_Framework.html)。 - MyKey_

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接