目录
- <!-- fegin客户端-->
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-openfeign</artifactId>
- </dependency>



发现不仅实现了远程调用,还实现了负载均衡


配置Feign日志有两种方式
在yml文件中添加
- feign:
- client:
- config:
- default:
- logger-level: FULL
- feign:
- client:
- config:
- userservice:
- logger-level: FULL
相较于之前的日志要详细许多


- <!-- HttpClient依赖-->
- <dependency>
- <groupId>io.github.openfeign</groupId>
- <artifactId>feign-httpclient</artifactId>
- </dependency>
- feign:
- httpclient:
- enabled: true
- max-connections: 200 #最大连接数
- max-connections-per-route: 50 #单个路径的最大连接数


1.首先创建一个module,命名为feign-api,然后引入feign的starter依赖

- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-openfeign</artifactId>
- </dependency>
- </dependencies>
2.将order-service中编写的UserClient、User、DefaultFeignConfiguration都复制到feign-api项目中

3.在order-service中引入feign-api的依赖

4.修改order-service中的所有与上述三个组件有关的import部分,改成导入feign-api中的包

5.重启测试
