<dependencies> <dependency> <groupId>io.dropwizard.client</groupId> <artifactId>dropwizard-client</artifactId> <version>2.0.0</version> </dependency> </dependencies> yaml httpClient: connectionTimeout: 5000 requestTimeout: 10000 maxConnections: 50 ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setConnectionTimeout(Duration.milliseconds(5000)); clientConfig.setRequestTimeout(Duration.milliseconds(10000)); clientConfig.setMaxConnections(50); HttpClient httpClient = new JerseyClientBuilder(environment) .using(clientConfig) .build("httpClient"); String url = "https://api.example.com/data"; Response response = httpClient.target(url) .request() .get(); JsonObject jsonResponse = response.readEntity(JsonObject.class);


上一篇:
下一篇:
切换中文