{"id":50350486,"url":"https://github.com/crossoverJie/feign-plus","last_synced_at":"2026-06-15T12:01:38.350Z","repository":{"id":40504349,"uuid":"282279114","full_name":"crossoverJie/feign-plus","owner":"crossoverJie","description":"A better feign client library to combine with SpringBoot.","archived":false,"fork":false,"pushed_at":"2024-05-16T17:25:47.000Z","size":374,"stargazers_count":72,"open_issues_count":2,"forks_count":42,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T18:48:33.889Z","etag":null,"topics":["annotation","feign","metri","metrics","springboot"],"latest_commit_sha":null,"homepage":"https://crossoverjie.top/tags/Feign/","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/crossoverJie.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":"2020-07-24T17:28:13.000Z","updated_at":"2024-03-05T02:17:29.000Z","dependencies_parsed_at":"2024-10-31T07:03:28.241Z","dependency_job_id":"3755c5b5-a1d5-436d-9658-55790bcb8eca","html_url":"https://github.com/crossoverJie/feign-plus","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"4ef2ab2cc1bc25134a4a4c6d161d40355872cabf"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/crossoverJie/feign-plus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crossoverJie%2Ffeign-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crossoverJie%2Ffeign-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crossoverJie%2Ffeign-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crossoverJie%2Ffeign-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crossoverJie","download_url":"https://codeload.github.com/crossoverJie/feign-plus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crossoverJie%2Ffeign-plus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34361403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["annotation","feign","metri","metrics","springboot"],"created_at":"2026-05-29T21:00:23.918Z","updated_at":"2026-06-15T12:01:38.343Z","avatar_url":"https://github.com/crossoverJie.png","language":"Java","funding_links":[],"categories":["HTTP客户端"],"sub_categories":["微服务框架"],"readme":"# feign-plus\n\nA better feign client library to combine with `SpringBoot`.\n\n---\n\n\n\nWrite [Feign](https://github.com/OpenFeign/feign) client with `annotation`, like this:\n\nWe can provider an interface.\n\n```java\n@RequestMapping(\"/v1/demo\")\n@FeignPlusClient(name = \"demo\", url = \"${feign.demo.url}\", port = \"${feign.demo.port}\")\npublic interface DemoApi {\n    @GetMapping(\"/id\")\n    String sayHello(@RequestParam(value = \"id\") Long id);\n\n    @GetMapping(\"/id/{id}\")\n    String id(@PathVariable(value = \"id\") Long id);\n\n    @PostMapping(\"/create\")\n    Order create(@RequestBody OrderCreateReq req);\n\n    @GetMapping(\"/query\")\n    Order query(@SpringQueryMap OrderQueryDTO dto);\n}\n```\n\nNow we can use it as we normally use `SpringBoot`.\n\n```java\n@SpringBootApplication\n@EnableFeignPlusClients(basePackages = \"com.example.provider.api\")\n@RestController\npublic class DemoApplication {\n\n\t@Resource\n\tprivate DemoApi demoApi;\n\n\t@GetMapping(value = \"/hello\")\n\tpublic String hello() {\n\t\tdemoApi.id(12L);\n\t\tdemoApi.sayHello(34L);\n\t\tdemoApi.create(new OrderCreateReq(\"100\"));\n\t\tdemoApi.query(new OrderQueryDTO(\"999\", \"zhangsan\"));\n\t\treturn \"hello\";\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tSpringApplication.run(DemoApplication.class, args);\n\t}\n\n}\n```\n\n# Feature\n\n- [x] Request/Response/Exception log record.\n- [x] Custom interceptor.\n- [x] Micrometer support.\n- [x] Exception passing.\n\n\n## Interceptor \nBy default, the request log is logged using the debug level.\n![](img/interceptor.jpg)\n\nFor custom interceptor you need to create a bean that extends the `DefaultLogInterceptor`. \n\n**Example usage:**\n```java\n@Component\n@Slf4j\npublic class CustomFeignInterceptor extends DefaultLogInterceptor {\n    @Override\n    public void request(String target, String url, String body) {\n        super.request(target, url, body);\n        log.info(\"request\");\n    }\n\n    @Override\n    public void exception(String target, String url, FeignException feignException) {\n        super.exception(target, url, feignException);\n    }\n\n    @Override\n    public void response(String target, String url, Object response) {\n        super.response(target, url, response);\n        log.info(\"response\");\n    }\n}\n```\n\n## Exception passing\n\nCustom exception like this:\n\n```java\n@Data\npublic class DemoException extends RuntimeException {\n    private String appName;\n    private int code;\n    private String debugStackTrace;\n}    \n```\n\n### Provier\n\nWhen the provider throws an exception:\n\n```java\n    @GetMapping(\"/query\")\n\tpublic Order query(OrderQueryDTO dto) {\n\t\tlog.info(\"dto = {}\", dto);\n\t\tif (dto.getId().equals(\"1\")) {\n\t\t\tthrow new DemoException(\"provider test exception\");\n\t\t}\n\t\treturn new Order(dto.getId());\n\t}\n```\n\nconsumer will get a return of HTTP_CODE = 500.\n\n```json\n{\n\"appName\": \"provider-demo\",\n\"code\": 500,\n\"message\": \"provider test exception\",\n\"debugStackTrace\": \"com.example.provider.api.exception.DemoException: provider test exception\\n\\tat com.exampl.provider.core.ProviderApplication.query(ProviderApplication.java:49)\\n\\tat\"\n}\n```\n\n### Consumer\n\nConfiguring an exception decoder:\n\n```java\n@Configuration\npublic class FeignExceptionConfig {\n    @Bean\n    public FeignErrorDecoder feignExceptionDecoder() {\n        return (methodName, response, e) -\u003e {\n            HttpStatus status = JSONUtil.toBean(response, HttpStatus.class);\n            return new DemoException(status.getAppName(), status.getCode(), status.getMessage(), status.getDebugStackTrace());\n        };\n    }\n}\n```\n\nthen the consumer can catch `DemoException` like local call:\n\n```java\n    try {\n        demoApi.query(new OrderQueryDTO(id, \"zhangsan\"));\n    } catch (DemoException e) {\n        log.error(\"feignCall:{}, sourceApp:[{}], sourceStackTrace:{}\", e.getMessage(), e.getAppName(), e.getDebugStackTrace(), e);\n    }\n```\n\n\n# More configuration\n\n```yaml\nfeign:\n  plus:\n    connect-timeout: 11000\n    max-idle-connections: 520\n    read-timeout: 12000\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FcrossoverJie%2Ffeign-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FcrossoverJie%2Ffeign-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FcrossoverJie%2Ffeign-plus/lists"}