3.2.2 支付微服务提供者Controller修改
@GetMapping("/payment/getInfo")
public ResponseResult getInfo() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String value = UUID.randomUUID().toString() + ":" + serverPort;
return new ResponseResult(200, "成功", value);
}

3.2.3.订单微服务消费者server
package cn.bdqn.service;
import cn.bdqn.bean.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@Component
@FeignClient(name="springcloud-payment-provider-service")
public interface PaymentFeignServer {
@GetMapping("/payment/get/{id}")
public ResponseResult queryId(@PathVariable(name = "id") Integer id);
@GetMapping("/payment/getInfo")
public ResponseResult getInfo();
}
3.2.4.订单微服务消费者controller
package cn.bdqn.controller;
import cn.bdqn.bean.ResponseResult;
import cn.bdqn.service.PaymentFeignServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class OrderController {
@Autowired
private PaymentFeignServer paymentFeiginService;
@GetMapping(value = "/consumer/payment/get/{id}")
public ResponseResult getPaymentByID(@PathVariable("id") Integer id) {
return paymentFeiginService.queryId(id);
}
@GetMapping(value = "/consumer/payment/getInfo")
public ResponseResult getInfo() {
return paymentFeiginService.getInfo();
}
}

3.2.6解决方案
server:
port: 80
eureka:
client:
register-width-eureka: false
service-url: # 配置服务中心,openFeign去里面找服务
defaultZone: http://eureka7001.com:7001/eureka/,
http://eureka7002.com:7002/eureka/,
http://eureka7003.com:7003/eureka/,
instance:
prefer-ip-address: true,
ribbon:
#指的是建立连接后从服务器读取到可用资源所用的时间
ReadTimeout: 5000
#指的是建立连接所用的时间 适用于网络状态正常的情况下,两端连接所用的时间
ConnectTimeout: 5000

4.3配置日志Bean
package cn.bdqn.config;
import feign.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FeignLogConfig {
@Bean
public Logger.Level feignLoggerLever(){
return Logger.Level.FULL;
}
}
4.4YML 文件里需要开启日志的Feign客户端
server:
port: 80
eureka:
client:
register-width-eureka: false
service-url: # 配置服务中心,openFeign去里面找服务
defaultZone: http://eureka7001.com:7001/eureka/,
http://eureka7002.com:7002/eureka/,
http://eureka7003.com:7003/eureka/,
instance:
prefer-ip-address: true,
ribbon:
#指的是建立连接后从服务器读取到可用资源所用的时间
ReadTimeout: 5000
#指的是建立连接所用的时间 适用于网络状态正常的情况下,两端连接所用的时间
ConnectTimeout: 5000
logging:
level:
cn.bdqn.service.PaymentFeignService: debug