{"id":18559137,"url":"https://github.com/linux-china/spring-boot-starter-okhttp3","last_synced_at":"2025-04-10T02:30:40.932Z","repository":{"id":136596269,"uuid":"58186149","full_name":"linux-china/spring-boot-starter-okhttp3","owner":"linux-china","description":"Spring Boot Starter for OkHttp3","archived":false,"fork":false,"pushed_at":"2016-05-06T06:33:28.000Z","size":9,"stargazers_count":56,"open_issues_count":1,"forks_count":29,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-02T02:51:14.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linux-china.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2016-05-06T06:33:14.000Z","updated_at":"2024-06-05T02:36:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb04b9bb-c67e-47e8-b6b7-26669e5dc72d","html_url":"https://github.com/linux-china/spring-boot-starter-okhttp3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fspring-boot-starter-okhttp3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fspring-boot-starter-okhttp3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fspring-boot-starter-okhttp3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fspring-boot-starter-okhttp3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linux-china","download_url":"https://codeload.github.com/linux-china/spring-boot-starter-okhttp3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144159,"owners_count":21054876,"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":[],"created_at":"2024-11-06T21:42:09.459Z","updated_at":"2025-04-10T02:30:40.927Z","avatar_url":"https://github.com/linux-china.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Spring Boot Starter OkHttp3\n===========================\n在Spring Boot下整合OkHttp3,方便客户端使用.\n\n### 为何要使用spring-boot-starter-httpclient\nOkHttp3已经非常简单啦,为何还需要创建一个starter,其主要的目的如下:\n\n* 让使用更简单,如全局proxy,timeout等\n* 结合dropwizard metrics,添加对metrics的管理\n* 全局控制okhttpclient\n\n### 如何使用\n\n* 在Spring Boot项目的pom.xml中添加以下依赖:\n\n          \u003cdependency\u003e\n                 \u003cgroupId\u003eorg.mvnsearch.spring.boot\u003c/groupId\u003e\n                 \u003cartifactId\u003espring-boot-starter-okhttp3\u003c/artifactId\u003e\n                 \u003cversion\u003e1.0.0-SNAPSHOT\u003c/version\u003e\n          \u003c/dependency\u003e\n\n* 接下来在你的代码中直接应用cacheManager，然后就可以啦。\n        \n            @Autowired\n            private OkHttpClient httpClient;\n\n### spring-boot-start-httpclient提供的服务\n\n* okhttp3.OkHttpClient: Http Client\n\n### 典型的例子:\n\n* http client: \n```\n           String url = \"http://ip.mvnsearch.org\";\n           Request request = new Request.Builder().url(url).build();\n           Response response = client.newCall(request).execute();\n           System.out.println(response.body().string());\n```\n\n### FAQ\n\n* OkHttpClient线程安全吗? 绝对线程安全, 而且JVM全局共享一个OkHttpClient, 性能更好\n\n\n### 参考文档\n\n* OkHttp : http://square.github.io/okhttp/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Fspring-boot-starter-okhttp3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinux-china%2Fspring-boot-starter-okhttp3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Fspring-boot-starter-okhttp3/lists"}