1.引入依赖包

<!-- 引入关于 eureka-server的依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>

2.主函数

@EnableEurekaClient
@EnableFeignClients

3.创建feign配置文件

package com.example.eurekafeignclient.config;

import feign.Retryer;
import org.springframework.context.annotation.Configuration; import java.util.concurrent.TimeUnit; @Configuration
public class feignConfig {
public Retryer feignRetryer() {
return new Retryer.Default(100, TimeUnit.SECONDS.toMillis(1), 5);
}
}//end

4.创建接口

package com.example.eurekafeignclient;

import com.example.eurekafeignclient.config.feignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping; @FeignClient(value = "eureka-client", configuration = feignConfig.class)
@Service
public interface imp_eurekaClientFeign {
@GetMapping(value = "/hello")
String hello11();
}//end

5.创建controller调用

package com.example.eurekafeignclient.controller;

import com.example.eurekafeignclient.imp_eurekaClientFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
public class clientController {
@Autowired
imp_eurekaClientFeign imp_eurekaClientFeign_;
@RequestMapping("/hello")
public String hello() {
return imp_eurekaClientFeign_.hello11();
}
}

springBoot Feign的更多相关文章

  1. springBoot Feign Hystrix

    1.引入依赖包 <!-- 引入关于 hystrix的依赖 --> <dependency> <groupId>org.springframework.cloud&l ...

  2. springboot feign too many bytes written executing POST

    解決办法: pom添加: <dependency><groupId>io.github.openfeign</groupId><artifactId>f ...

  3. Springboot feign 传递request信息

    基础实现 requestInterceptor 实现类中添加信息 public class NativeFeignConf { @Bean public RequestInterceptor getR ...

  4. springBoot Feign Hystrix Dashboard

    1.引入依赖 <!-- 引入关于 hystrix Dashboard的依赖 --> <dependency> <groupId>org.springframewor ...

  5. Solon 特性简集,相较于 Springboot 有什么区别?

    Solon 是一个类似Springboot的微型开发框架,也是一个不基于Servlet的开发框架.项目从2018年启动以来,参考过大量前人作品:历时两年,3500多次的commit:内核保持0.1m的 ...

  6. 不使用SpringBoot如何将原生Feign集成到Spring中来简化http调用

    在微服务架构中,如果使用得是SpringCloud,那么只需要集成SpringFeign就可以了,SpringFeign可以很友好的帮我们进行服务请求,对象解析等工作. 然而SpingCloud是依赖 ...

  7. springboot+cloud 学习(二)应用间通信Feign(伪RPC,实则HTTP)

    在微服务中,使用什么协议来构建服务体系,一直是个热门话题. 争论的焦点集中在两个候选技术:  RPC or Restful Restful架构是基于Http应用层协议的产物,RPC架构是基于TCP传输 ...

  8. Springboot中Feign的使用总结

    Feign是Webservice服务的客户端,创建接口+注解就可完成,实现简单 客户端通过@EnableFeignClients开启Feign的支持功能 @SpringBootApplication ...

  9. SpringBoot:使用feign调用restful服务时地址栏传参

    1.服务提供者(controller层) @GetMapping("/user/{id}") public ApiResult getById(@PathVariable(&quo ...

随机推荐

  1. python datetime offset-aware与offset-navie相互转换

    python datetime offset-aware与offset-navie相互转换 2016年11月13日 16:20:43 阅读数:2393 有时,我们使用python 的datetime模 ...

  2. Result Maps collection does not contain value for xxxx

    这是mybatis查询返回值的错误,我在做一个查询数值的方法,但是我是这样写的: <select id="findSize" resultMap="long&quo ...

  3. 【Insert Interval】cpp

    题目: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if nec ...

  4. 收集的java面试题

    1.谈谈final, finally, finalize的区别. final—修饰符(关键字)如果一个类被声明为final,意味着它不能再派生出新的子类,不能作为父类被继承.因此一个类不能既被声明为 ...

  5. 浅谈 css 之 position用法

    在 css中, position 属性有四个值可用: static(默认值).absolute.relative.fixed. relative:相对定位(相对于自身进行在常规流中的位置进行定位,保留 ...

  6. linux->centos7设置tomcat开机自启

    找到/etc/rc.d/文件下的rc.local,添加如下内容 export JAVA_HOME=/usr/local/jdk1.8.0_144export JRE_HOME=$JAVA_HOME/j ...

  7. ASP.NET Core 2.1 源码学习之 Options[3]:IOptionsMonitor 【转】

    原文链接:https://www.cnblogs.com/RainingNight/p/strongly-typed-options-ioptions-monitor-in-asp-net-core. ...

  8. 设计模式之模板方法模式 templateMethod

    代码实现 public abstract class BankTemplateMethod { //具体方法 public void takeNumber(){ System.out.println( ...

  9. 原始套接字--简易ping程序

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> ...

  10. sqlserver 汉字转拼音 索引 函数

    IF OBJECT_ID('[fn_GetPinyin]') IS NOT NULL DROP FUNCTION [fn_GetPinyin] GO create function [dbo].[fn ...