依赖:

<properties>
<java.version>1.8</java.version>
<feign-core.version>10.2.0</feign-core.version>
<feign-form.version>2.1.0</feign-form.version>
</properties>


        <dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
<version>${feign-core.version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jackson</artifactId>
<version>${feign-core.version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form</artifactId>
<version>${feign-form.version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form-spring</artifactId>
<version>${feign-form.version}</version>
</dependency>

或者直接使用依赖:

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

配置:

@Configuration
@ComponentScan(basePackages = "com.icil.elsa.subscribe.milestone.command.web.job")
public class XxlJobConfig { /* @Autowired
private ObjectFactory<HttpMessageConverters> messageConverters*/; private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); @Value("${xxl.job.admin.addresses}")
private String adminAddresses;// http:127.0.0.1:8888
//define feign client
@Bean
public XxService xxService() {
return Feign.builder()
// .encoder(new FormEncoder(new JacksonEncoder())) //如果有表单提交,加上表单编解码
// .decoder(new JacksonDecoder())            //
.target(XxlJobService.class, adminAddresses);
}
}
XxService:
import com.alibaba.fastjson.JSONObject;
import feign.Headers;
import feign.Param;
import feign.RequestLine; import java.util.Map; public interface XxlJobService { @RequestLine("GET /ufl-job-admin/jobinfo/pageList?jobGroup={jobGroup}")
JSONObject pageList(@Param(value = "jobGroup") int jobGroup); @RequestLine("POST /ufl-job-admin/jobinfo/add")
@Headers("Content-Type: application/x-www-form-urlencoded")
JSONObject add(Map<String, ?> form); @RequestLine("GET /ufl-job-admin/jobinfo/start?id={id}")
JSONObject start(@Param(value = "id") int id); @RequestLine("GET /ufl-job-admin/jobinfo/stop?id={id}")
JSONObject stop(@Param(value = "id") int id);
}
 

feign client 的简单使用(1)的更多相关文章

  1. Feign Client 原理和使用

    Feign Client 原理和使用 一块石头 ​ 公众号:好奇心森林 ​关注他 创作声明:内容包含虚构创作 6 人赞同了该文章 最近一个新项目在做后端HTTP库技术选型的时候对比了Spring We ...

  2. No fallback instance of type class found for feign client user-service(转)

    1.错误日志 在 feign 开启熔断,配置 fallback 类,实现当前接口的实现类时,报错信息如下: Error starting ApplicationContext. To display ...

  3. spring cloud feign覆写默认配置级feign client的日志打印

    一.覆写fegin的默认配置 1.新增配置类FeignConfiguration.java package com.config; import org.springframework.context ...

  4. No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-netflix-ribbon?

    ... 60 common frames omittedCaused by: java.lang.IllegalStateException: No Feign Client for loadBala ...

  5. spring cloud关于feign client的调用对象列表参数、设置header参数、多环境动态参数试配

    spring cloud关于feign client的调用 1.有些场景接口参数需要传对象列表参数 2.有些场景接口设置设置权限等约定header参数 3.有些场景虽然用的是feign调用,但并不会走 ...

  6. spring cloud多个消费端重复定义feign client问题

    spring cloud消费端调用服务提供者,有两种方式rest+ribbon和Feign,Feign是一个声明式的伪Http客户端更为简单易用,所以我们项目选用Feign作为服务通讯方式 项目有6个 ...

  7. client交互技术简单介绍

    随着网络应用的不断丰富,client交互技术也如雨后春笋一般,遍地开花. 正是这些技术的支持,我们的互联网世界变得更加丰富多彩.一个浏览器上.不用说是简单的动画效果,就是一个Office应用也能顺畅的 ...

  8. Feign【替换默认的feign client】

    说明: feign默认情况下使用的是JDK原始的URLConnection发送的HTTP请求,没有使用到连接池,但是对每个地址会保持长连接,即HTTP的persistence connection.我 ...

  9. Is it possible to create @Around Aspect for feign.Client

    https://github.com/spring-cloud/spring-cloud-openfeign/issues/59 看到github 有人问这个问题,做了个示例: import org. ...

随机推荐

  1. 黄聪:HBuilder左侧项目管理器如何不与标签页一起自动切换

    把这个按钮取消就好了

  2. CentOS 7下NFS Server作rootfs时的兼容性问题

    最近新装CentOS 7,发现原先CentOS 6.3下可用的一块ARM Dev board不能用了,表现为VFS mount挂载rootfs失败. 使用WireShark发现,服务器对client发 ...

  3. 数据仓库专题18-数据建模语言IDEF(转载)

    1引言 IDEF的含义是集成计算机辅助制造(Integrated Computer-AidedManufacturing,ICAM)DEFinition.最初的IDEF方法是在美国空军ICAM项目建立 ...

  4. Linux CentOS 下关闭防火墙

    永久关闭(重启后生效) 开启: chkconfig iptables on 关闭: chkconfig iptables off 临时关闭(重启后失效) 开启: service iptables st ...

  5. hierarchical_mutex函数问题(C++ Concurrent in Action)

    C++ Concurrent in Action(英文版)书上(No.52-No.53)写的hierarchical_mutex函数,只适合结合std::lock_guard使用,直接使用如果不考虑顺 ...

  6. ​游戏设计思考:对COK的理解和思考

    转自:http://www.gameres.com/804983.html 一.前言 发此文的起因是最近加入了一个游戏研究群,受到大家对游戏研究热情的感染,也想将自己对游戏的理解和感悟发出来和大家一起 ...

  7. java 获取两个日期之间的所有天数

    Calendar start = Calendar.getInstance(); start.set(2017, 2, 20); Long startTIme = start.getTimeInMil ...

  8. jQuery动态创建DOM节点

    var SKU=$("#SKU"); // 通过ID查找到指定表格 var oTable=SKU[0]; // 获取第一个表格 // 获取正文tbody元素 var tBodies ...

  9. 第9章 应用层(2)_动态主机配置协议(DHCP)

    2. 动态主机配置协议(DHCP) 2.1 静态地址和动态地址的应用场景 (1)静态地址应用场景 ①IP地址不经常更改的设备(如服务器地址) ②使用有规律的IP地址以便于管理(如学校机房为方便教师管理 ...

  10. dataset to list

    http://www.c-sharpcorner.com/UploadFile/ee01e6/different-way-to-convert-datatable-to-list/ http://ww ...