https://blog.csdn.net/kirk15951859811/article/details/117067488
@FeignClient(name="mekFeignClient",fallback = MekFeignClientFallback.class,configuration = RemoteFeignConfig.class) public interface MekFeignClient { @RequestLine("GET") String list(URI uri); }
@Slf4j @Component @Import(FeignClientsConfiguration.class) public class CallerService { MekFeignClient mekFeignClient; // 创建构造器 // 调用类以构建函数(Constructor) 的方式注入 FeignClient 类 public BusiProcessService(Decoder decoder, Encoder encoder, Client client) { mekFeignClient = Feign.builder().client(client).encoder(encoder).decoder(decoder) .target(Target.EmptyTarget.create(MekFeignClient.class)); } public String test() { // 请求地址,MEK为服务名 String url = "http://MEK/model/list"; String res = ""; //使用FeignClient请求服务 try { res = mekFeignClient.list(new URI(url)); }catch (Exception e){ logger.error("feign call error,cause:{}",e); } return GsonUtils.toJsonString(res); } }
标签:FeignClient,Feign,String,URL,mekFeignClient,public,decoder,转载,class From: https://www.cnblogs.com/tju1895/p/17631533.html