Spring Boot application integrates HttpClient quickly.
- Import dependencies
<dependency>
<groupId>cn.unikue.springstarter</groupId>
<artifactId>http-client-spring-boot-starter</artifactId>
<version>LATEST</version>
</dependency>By default, this starter will auto take effect, you can turn it off by
spring.http-client.enabled = false
- Configure Spring Boot
application.ymlwith prefixspring.http-client
spring:
http-client:
sync-client:
user-agent: 'Apache-HttpClient'
async-client:
user-agent: 'Apache-HttpClient'- This starter creates two beans as follows, then you can configure your beans by constructor or
@Autowired/@Resourceannotation, then you can access it.
| Bean Name | Bean Class |
|---|---|
| syncHttpClient | org.apache.hc.client5.http.classic.HttpClient |
| asyncHttpClient | org.apache.hc.client5.http.async.HttpAsyncClient |
- Github: https://github.com/unikueltd/http-client-spring-boot-starter
- HttpClient github: https://github.com/apache/httpcomponents-client
- HttpClient homepage: https://hc.apache.org
- jdk 17+
This project is under the Apache License 2.0
See the NOTICE.txt file for required notices and attributions.
You like this package? Then donate to us to support the development.
Beijing Unikue Network Technology Ltd.
- Unikue: https://unikue.cn