本文共 1325 字,大约阅读时间需要 4 分钟。
??????OpenFeign????????????Feign????????????Maven????
org.springframework.cloud spring-cloud-starter-openfeign
?????????@SpringBootApplication?@EnableFeignClients??????OpenFeign??????????????
@SpringBootApplication@EnableEurekaClient@EnableFeignClientspublic class OrderFeignMain80 { public static void main(String[] args) { SpringApplication.run(OrderFeignMain80.class, args); }} ??Feign???????????????????????
@Component@FeignClient(value = "CLOUD-PAYMENT-SERVICE")public interface PaymentFeignService { @GetMapping(value = "/payment/get/{id}") public CommonResult getPaymentById(@PathVariable("id") Long id);} OpenFeign????Ribbon???????????????????????
ReadTimeout: 6000ms????????????ConnectTimeout: 6000ms???????????????????????????????????????????????????
try { Thread.sleep(10000L);} catch (InterruptedException e) { e.printStackTrace();} ?????????Feign????????????????????
@Configurationpublic class FeignConfig { @Bean public Logger.Level feignLoggerLevel() { return Logger.Level.FULL; }} ???????????????????????????
????????????????Feign??????????????????????????
转载地址:http://jlon.baihongyu.com/