8
從com.sun.jersey.api.client.Client到javax.ws.rs.client.Client如何配置客戶端?javax.ws.rs.client.Client如何配置readTimeOut?
FROM:
import com.sun.jersey.api.client.Client;
Client client = Client.create();
client.setReadTimeout(1000 * 60 * 20);
client.setConnectTimeout(1000 * 20);
webResource = client.resource("someWhereOverTheRainbow");
..etc.
TO:
import javax.ws.rs.client.*;
Client client = ClientBuilder.newClient();
// **now what?** client.getConfiguration().getProperties().put("isThisTheWayToDoIt", 1000 * 60 * 2);
WebTarget target = client.target("someWhereOverTheRainbow");
..etc.
'ClientConfig'可能是不可變的。因此,'configuration.property()'不保證返回'this'。您有責任將結果返回給「配置」,否則您有可能丟失財產。 – Gili
@Gili非常感謝您指出我的錯誤。 – longhua
是ClientConfig和ClientProperties沒有球衣特定的類嗎?我認爲問題是通過JAX-RS API –