依赖:

<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. Java第04次实验提纲(面向对象2-继承、多态、抽象类与接口)

    PTA 题集面向对象2-进阶-多态接口内部类 第1次实验 1.1 题集5-1(Comparable) 难点:如果传入对象为null,或者传入对象的某个属性为null,怎么处理? 1.2 题集5-2(C ...

  2. ALGO-123_蓝桥杯_算法训练_A+B problem

    问题描述 Given two integers A and B, your task is to output their sum, A+B. 输入格式 The input contains of o ...

  3. gitlab 10.8.1 迁移

    参考官网: https://docs.gitlab.com/ee/raketasks/backup_restore.html    Backing up and restoring GitLab 及 ...

  4. C/C++基础----关联容器

    基本属性 与顺序容器的差别,按照关键字来保存和访问,而顺序容器是按照容器中的位置来顺序保存和访问. map:每个元素是一对键值(key-valye)组合:set每个元素只包含关键字.. 每个根据关键字 ...

  5. 1119.(重、错)Pre- and Post-order Traversals

    题目大意: 给定一棵树的结点个数n,以及它的前序遍历和后序遍历,输出它的中序遍历: 如果中序遍历不唯一就输出No,且输出其中一个中序即可,如果中序遍历唯一就输出Yes,并输出它的中序 思路:(转载) ...

  6. [转载]领域驱动设计(Domain Driven Design)参考架构详解

    摘要 本文将介绍领域驱动设计(Domain Driven Design)的官方参考架构,该架构分成了Interfaces.Applications和Domain三层以及包含各类基础设施的Infrast ...

  7. vue 数据绑定 绑定属性 循环渲染数据

    <template> <!-- vue的模板里面 所有的内容要被一个根节点包含起来 --> <div id="app"> <h2>{ ...

  8. angular4+中的数据绑定

    1,基本的属性绑定,下面的两种形式是一样的 2.dom属性和html属性 3.两者关系的进一步总结 4.dom属性绑定 5.html属性绑定

  9. Hadoop 2.x常用端口及查看方法

    Hadoop集群的各部分一般都会使用到多个端口,有些是daemon之间进行交互之用,有些是用于RPC访问以及HTTP访问.而随着Hadoop周边组件的增多,完全记不住哪个端口对应哪个应用,特收集记录如 ...

  10. delphi 获取webbrowser的cookies给Idhttp用

    网上方法一:(可获取,但不完全) 引用mshtml; IHTMLDocument(wb1.Document).cooke; 网上方法二:(获取不到!) 引用winnet,使用InternetGetCo ...