EnableFeignClients基本配置
pom.xml
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-feign</artifactId>
- <version>1.3.1.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <version>1.5.4.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.5.3</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-eureka</artifactId>
- <version>1.3.1.RELEASE</version>
- </dependency>
spring 配置
- spring:
- application:
- name: service-feign
- server:
- port: 8762
- eureka:
- client:
- serviceUrl:
- defaultZone: http://localhost:8761/eureka/
启动类
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
- import org.springframework.cloud.netflix.feign.EnableFeignClients;
- @EnableFeignClients
- @EnableDiscoveryClient
- @SpringBootApplication
- public class App
- {
- public static void main( String[] args )
- {
- SpringApplication.run(App.class, args);
- }
- }
测试Controller
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- @RestController
- public class TestController {
- @Autowired
- private TestService testService;
- @RequestMapping(value = "/hi", method = RequestMethod.GET)
- public String sayHi(@RequestParam String name) {
- return testService.testGet(1L);
- }
- }
测试Service
- import org.springframework.cloud.netflix.feign.FeignClient;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- @FeignClient(value = "uninoty")
- public interface TestService {
- @RequestMapping(value = "/manage/sms/msg/{id}",method = RequestMethod.GET)
- String testGet(@RequestParam(value="id") Long id);
- }
EnableFeignClients基本配置的更多相关文章
- 注解 @EnableFeignClients 工作原理
概述在Spring cloud应用中,当我们要使用feign客户端时,一般要做以下三件事情 : 使用注解@EnableFeignClients启用feign客户端:示例 : @SpringBootAp ...
- @EnableFeignClients 客户端详细
在Spring cloud应用中,当我们要使用feign客户端时,一般要做以下三件事情 : 1.使用注解@EnableFeignClients启用feign客户端: 示例 : @SpringBootA ...
- 一、openfeign的自动配置
所有文章 https://www.cnblogs.com/lay2017/p/11908715.html 正文 openfeign是一种声明式的webservice客户端调用框架.你只需要声明接口和一 ...
- Feign源码解析系列-注册套路
感谢不知名朋友的打赏,感谢你的支持! 开始 在追寻Feign源码的过程中发现了一些套路,既然是套路,就可以举一反三,所以值得关注. 这篇会详细解析Feign Client配置和初始化的方式,这些方式大 ...
- 客户端远程调用Feign
客户端远程调用 Feign 什么是Feign? Feign是 Netflix 公司开源的声明式HTTP客户端 Github : Feign 源码 为什么需要Feign? 原代码可读性不高 复杂的URL ...
- SpringCloud 源码系列(6)—— 声明式服务调用 Feign
SpringCloud 源码系列(1)-- 注册中心 Eureka(上) SpringCloud 源码系列(2)-- 注册中心 Eureka(中) SpringCloud 源码系列(3)-- 注册中心 ...
- Spring Cloud 源码分析之OpenFeign
OpenFeign是一个远程客户端请求代理,它的基本作用是让开发者能够以面向接口的方式来实现远程调用,从而屏蔽底层通信的复杂性,它的具体原理如下图所示. 在今天的内容中,我们需要详细分析OpenFei ...
- 笔记:Spring Cloud Feign 其他配置
请求压缩 Spring Cloud Feign 支持对请求与响应进行GZIP压缩,以减少通信过程中的性能损耗,我们只需要通过下面二个参数设置,就能开启请求与响应的压缩功能,yml配置格式如下: fei ...
- SpringCloud注解和配置以及pom依赖说明
在本文中说明了pom依赖可以支持什么功能,以及支持什么注解,引入该依赖可以在application.properties中添加什么配置. 1.SpringCloud 的pom依赖 序号 pom依赖 说 ...
随机推荐
- Netty解决粘包和拆包问题的四种方案
在RPC框架中,粘包和拆包问题是必须解决一个问题,因为RPC框架中,各个微服务相互之间都是维系了一个TCP长连接,比如dubbo就是一个全双工的长连接.由于微服务往对方发送信息的时候,所有的请求都是使 ...
- Spring(三)使用JdbcTemplate对象完成查询
查询银行账户的数量 1.建立一个项目导入jar包(ioc aop dao 连接池 数据库驱动 ),拷贝容器对应的配置文件到src下 2.在配置文件中开启组件扫描 3.写一个DAO接口定义一个查询方法 ...
- 《JavaScript高级程序设计》笔记:表单脚本(十四)
表单的基础知识 在HTML中,表单是由<form>元素来表示的,而在JS中,表单对应的是HTMLFormElement类型.HTMLFormElement继承了HTMLElement,因而 ...
- wordpress的excerpt()函数
问题:在wordpres中的single页面,本身引用的<?php the_excerpt(); ?>,但是在页面上显示的却是文章的内容 原因:the_excerpt(); 在excerp ...
- Java实现"命令式"简易文本编辑器原型
源自早先想法, 打算从界面方向做些尝试. 找到个简单文本编辑器的实现: Simple Text Editor - Java Tutorials. 原本的菜单/按钮界面如下. 包括基本功能: 新建/打开 ...
- SAP MM '独立/集中'等于1的MTS物料MRP运行后合并需求触发PR
SAP MM '独立/集中'等于1的MTS物料MRP运行后合并需求触发PR Test data 独立与集中: 1 (仅个别需求) STO 1, 这是一个公司间STO,从国内生产基本转入香港贸易公司, ...
- 五一出门必备的手机APP神器 让你瞬间大开眼界
如今我们手机上有各种各样的软件,但是比较实用的又有哪些呢?所以每次大家都会花上很久的时间去查找满意的软件吧!今天就给大家送上一波福利,因为五一小长假就要到来了,说不定大家会使用到呢! 轻颜相机 轻颜相 ...
- Python数据处理与计算——概述
Python是一种面向对象的,动态的程序设计语言,具有非常简洁而清晰的语法,适合于完成各种高层任务.它既可以用来快速开发程序脚本,也可以用来开发大规模的软件. 随着NumPy.SciPy.Matplo ...
- mpvue学习笔记-之微信小程序数据请求封装
简介 美团出品的mpvue已经开源出来很久了,一直说要进行一次实践,这不最近一次个人小程序开发就用上了它. 看了微信官方的数据请求模块--request,对比了下get和post请求的代码,发现如果在 ...
- Java 基于ArcFace人脸识别2.0 服务端Demo
源代码传送:https://github.com/itboyst/ArcSoftFaceDemo 开发环境准备: ###开发使用到的软件和工具: Jdk8.mysql5.7.libarcsoft_fa ...