Feign的自定义配置

来源:互联网 发布:mac改壁纸 编辑:程序博客网 时间:2024/05/16 13:39

(1)自定义配置:

如果Eureka添加了安全验证,则需要配置上面的用户名、密码.

(2)在feignClient类中修改@FeignClient注解,在注解中添加新定义的Feign配置configuration的值:


注意:服务提供者的接口参数必须写在请求路径中,否则请求无效。

不使用自定义的feignClint配置:

(3)在Controller方法中引入定义好的FeignClient,实现对应接口信息访问:

(4)Feign日志打印配置

在configuration文件中添加feign日志配置:

在application配置文件中添加feign日志配置:

(5)FeignClient第一次请求报TimeOut问题解决方案:

  • 延长hystix的连接超时时间,默认时间是1秒

在application配置文件中添加如下配置:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds:5000

  • 禁用hystix的超时时间

在application配置文件中添加如下配置:

hystrix.command.default.execution.timeout.enabled: false

  • 禁用hystix

在application配置文件添加如下配置信息:

feign.hystrix.enabled: false

  • 参考网址:

超时的issue:

        https://github.com/spring-cloud/spring-cloud-netflix/issues/768

超时的解决方案:

        https://stackoverflow.com/questions/27375557/hystrix-command-fails-with-timed-out-and-no-fallback-available

(6)参照网址:

http://blog.csdn.net/jsu_9207/article/details/71745622?utm_source=itdadao&utm_medium=referral

http://blog.csdn.net/chenqipc/article/details/53322796

原创粉丝点击