{"id":15196859,"url":"https://github.com/maciejwalkowiak/spring-boot-http-clients","last_synced_at":"2025-10-28T04:31:28.193Z","repository":{"id":204499851,"uuid":"623651187","full_name":"maciejwalkowiak/spring-boot-http-clients","owner":"maciejwalkowiak","description":"Spring Boot HTTP Clients provides zero-boilerplate auto-configuration for WebClient and Spring 6 HTTP Interface based HTTP clients in a Spring Boot application.","archived":false,"fork":false,"pushed_at":"2023-10-30T15:56:56.000Z","size":108,"stargazers_count":105,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-01T11:24:39.666Z","etag":null,"topics":["httpclient","spring","spring-boot","spring-framework","webclient"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maciejwalkowiak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"maciejwalkowiak"}},"created_at":"2023-04-04T19:56:52.000Z","updated_at":"2024-12-19T12:33:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0ddb6c0-bcd3-4e40-80a9-b11b4be99e06","html_url":"https://github.com/maciejwalkowiak/spring-boot-http-clients","commit_stats":null,"previous_names":["maciejwalkowiak/spring-boot-http-clients"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejwalkowiak%2Fspring-boot-http-clients","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejwalkowiak%2Fspring-boot-http-clients/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejwalkowiak%2Fspring-boot-http-clients/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejwalkowiak%2Fspring-boot-http-clients/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maciejwalkowiak","download_url":"https://codeload.github.com/maciejwalkowiak/spring-boot-http-clients/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238597386,"owners_count":19498396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["httpclient","spring","spring-boot","spring-framework","webclient"],"created_at":"2024-09-28T00:05:03.964Z","updated_at":"2025-10-28T04:31:24.629Z","avatar_url":"https://github.com/maciejwalkowiak.png","language":"Java","funding_links":["https://github.com/sponsors/maciejwalkowiak"],"categories":["网络编程"],"sub_categories":["Spring Cloud框架"],"readme":"# Spring Boot HTTP Clients\n\n**Spring Boot HTTP Clients** provides zero-boilerplate auto-configuration for `WebClient` and Spring 6 HTTP Interface based HTTP clients in a **Spring Boot** application.\n\n\u003e **Note**\n\u003e The project is in the early stage, so expect breaking changes.\n\nSpring 6 introduced a new way to define HTTP clients using interfaces - [HTTP Interfaces](https://docs.spring.io/spring-framework/docs/current/reference/html/integration.html#rest-http-interface) (introduction video: [🚀 New in Spring Framework 6: HTTP Interfaces](https://www.youtube.com/watch?v=A1V71peRNn0)).\n\nRight now, setting up an HTTP client requires a bit of boilerplate code:\n\n1. Create a property for the base url. \n2. Create a `WebClient` bean which uses this property\n3. Create an `HttpServiceProxyFactory`.\n\nThis project aims to simplify this process and provide ease of creating HTTP clients similar to [Spring Cloud OpenFeign](https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/).\n\n\u003e **Note**\n\u003e It's very likely that Spring Boot will eventually implement its own way to autoconfigure HTTP clients, and this project will become deprecated. Look for updates on this topic here: [#31337](https://github.com/spring-projects/spring-boot/issues/31337)\n\n## 🤔 How to install\n\nAdd the dependency to `spring-boot-http-clients`:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.maciejwalkowiak.spring\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-http-clients\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## ✨ How to use\n\n1. Define HTTP clients in `application.yml` or `application.properties` under the prefix `http.clients`:\n\n```yaml\nhttp.clients:\n  todo-client:\n    url: https://jsonplaceholder.typicode.com/todos\n  user-client:\n    url: https://jsonplaceholder.typicode.com/users\n```\n\nThe client names (in the above example, `todo-client` and `user-client`) are just strings - use anything that makes sense - they are going to be used to construct the `WebClient` bean name.\n\nThe above code gets processed by `WebClientsAutoConfiguration`, which creates a bean of type `WebClient` with the name `\u003cclient-name\u003e.WebClient`.\n\n2. Define an HTTP client with Spring 6 HTTP Interface, annotate it with `@HttpClient`, and set the client name as the parameter:\n\n```java \n@HttpClient(\"todo-client\")\npublic interface TodoClient {\n    @GetExchange\n    List\u003cTodo\u003e get();\n}\n```\n\n3. That's it! Now you can inject `TodoClient` anywhere in your code 🙃\n\n## 🛠️ Advanced usage\n\nAutoconfigured `WebClient` instances are the result of calling Spring Boot autoconfigured `WebClient.Builder#build`, which allows defining custom `WebClientCustomizer` that get applied on the `WebClient` beans.\n\nIf for any reason you cannot rely on the autoconfigured `WebClient`, but you still want to use autoconfigured HTTP Interface based HTTP client, make sure to create a bean with name `\u003cclient-name\u003e.WebClient`, which will be picked up to create an HTTP client.\n\n### Customizing Headers\nDefault headers can be set in `application.yml` or `application.properties` under the prefix `http.clients.\u003cclient-name\u003e.headers` key. \n\n```yaml\nhttp.clients:\n  todo-client:\n    url: https://jsonplaceholder.typicode.com/todos\n    headers:\n      X-My-Header: my-value-x\n      Y-My-Header: ${DYNAMIC_VALUE:default-value}\n```\n\n### Customizing Cookies\nDefault cookies can be set in `application.yml` or `application.properties` under the prefix `http.clients.\u003cclient-name\u003e.cookies` key.\n\n```yaml\nhttp.clients:\n  todo-client:\n    url: https://jsonplaceholder.typicode.com/todos\n    cookies:\n      someCookie: cookie-value\n      someDynamicCookie: ${DYNAMIC_VALUE:default-value}\n```\n\n### Adding Filters\n[Filter functions](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/reactive/function/client/ExchangeFilterFunction.html) can be defined in `application.yml` or `application.properties` under the prefix `http.clients.\u003cclient-name\u003e.filters` key.\n\n```yaml\nhttp.clients:\n  todo-client:\n    url: https://jsonplaceholder.typicode.com/todos\n    filters:\n      - filterFunction\n      - filterFunction2\n```\n\n## 👥 Contributing\n\nIf you found a bug or a missing feature - you're very welcome to submit an issue and a pull request with a fix.\nNote, that this library is intended only to glue things together and not to compensate on the missing features in Spring's support for HTTP interfaces.\n\nSounds good? Consider [❤️ Sponsoring](https://github.com/sponsors/maciejwalkowiak) the project! Thank you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaciejwalkowiak%2Fspring-boot-http-clients","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaciejwalkowiak%2Fspring-boot-http-clients","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaciejwalkowiak%2Fspring-boot-http-clients/lists"}