zoukankan      html  css  js  c++  java
  • [spring cloud] feign声明

    feign声明@PathVariable

    @FeignClient(name = "TUZI")
    public interface TuziClientService{
        @GetMapping("/demo/get/{id}")
        Tuzi get(@PathVariable(value="id") int id);//value需要显式声明,否则报错
    }
    

    @PathVariable必须要显示声明value

    feign 返回InputStream

    @FeignClient(contextId = "remoteDemoService", name = ItepServiceConstants.SERVICE_NAME, path = "demo"
    //    ,configuration = RemoteDemoService.ClientConfiguration.class
    )
    public interface RemoteDemoService {
        @GetMapping("getById")
        ApiResult<demo> getById(String id);
    
    
        @GetMapping(value = "download")
        ApiResult download()
            throws IOException;
    
        class ClientConfiguration {
    
            @Autowired
            private ObjectFactory<httpmessageconverters> messageConverters;
    
            @Bean
            public Decoder feignDecoder () {
                return new Decoder() {
                    @Override
                    public Object decode(Response response, Type type)
                        throws IOException, DecodeException, FeignException {
                        return response.body().asInputStream();
                    }
                };
            }
        }
    }
    ```</httpmessageconverters></demo>
  • 相关阅读:
    Shell-17--break-exit-continue-shift
    Shell-16--函数
    Shell-14--awk
    TCP带外数据读写
    Linux网络编程-----Socket地址API
    log4j日志级别
    JNI-Test
    游戏服务器当中的唯一名设计方法
    String和bytes的编码转换
    base64的一个应用情景
  • 原文地址:https://www.cnblogs.com/zhuxiang1633/p/15511685.html
Copyright © 2011-2022 走看看