标签:.exe group 依赖 lock dex compiler 同步请求 mave exec
This class support asynchronous and synchronous HTTP requests.
AsyncHttpClient 支持同步、异步Http请求。
<dependencies>
<dependency>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>net.tascalate</groupId>
<artifactId>net.tascalate.concurrent</artifactId>
<version>0.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
/**
* 执行同步HTTP请求
*/
public void synRequest() {
String url = "http://www.baidu.com";
AsyncHttpClient c = new DefaultAsyncHttpClient();
Future<Response> f = c.prepareGet(url).execute();
try {
System.out.println(f.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
《AsyncHttpClient 官方文档》
HttpClient学习(三)—— AsyncHttpClient使用
标签:.exe group 依赖 lock dex compiler 同步请求 mave exec
原文地址:https://www.cnblogs.com/fonxian/p/10902172.html