当前位置:网站首页>Feign use
Feign use
2022-07-25 12:14:00 【dengjili】
Feign Introduce
Feign It belongs to one of interface calls ,
| name | explain |
|---|---|
| Httpclient | HttpClient yes Apache Jakarta Common Sub projects under , To provide efficient 、 Abreast of the times 、 Feature rich support Http Client programming toolkit for protocol , And it supports HTTP The latest version of the agreement and recommendations .HttpClient Compared with tradition JDK Self contained URLConnection, Improved ease of use and flexibility , Make the client send HTTP It's easier to ask , Improved development efficiency . |
| Okhttp | An open source project to handle network requests , It's the most popular lightweight framework in Android , from Square The company contributed , Used in substitution HttpUrlConnection and Apache HttpClient.OkHttp Have a simple API、 Efficient performance , And support a variety of protocols (HTTP/2 and SPDY). |
| HttpURLConnection | HttpURLConnection yes Java Standard class , It is inherited from URLConnection, Can be used to send GET request 、POST request .HttpURLConnection It's complicated to use , Unlike HttpClient That's easy to use . |
| RestTemplate | RestTemplate yes Spring Provided for access Rest Client of service ,RestTemplate Provides a variety of convenient remote access HTTP Method of service , Can greatly improve the writing efficiency of the client . |
| Feign | Feign It's a declarative one REST client , It can make REST It's easier to call .Feign For HTTP Requested template , By writing simple interfaces and inserting annotations , You can define HTTP Requested parameters 、 Format 、 Address and other information . and Feign It'll be a complete agent HTTP request , We only need to call it like a method to complete the service request and related processing .Spring Cloud Yes Feign It was packaged , To support SpringMVC Standard notes and HttpMessageConverters.Feign It can be done with Eureka and Ribbon Combined to support load balancing . |
Get ready
start-up Eureka service , And register two applications as test cluster machines , As shown in the figure ; Test interface /hello
Feign Project use
To configure pom.xml rely on
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
encapsulation Feign Interface ,eureka-provider-app To register to Eureka Service name in
@FeignClient(value = "eureka-provider-app")
public interface TestClient {
@GetMapping("/hello")
String hello();
}
To configure client scanning
@SpringBootApplication
@EnableFeignClients(basePackageClasses = {
TestClient.class})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
The configuration file application.properties add to Eureka Registration configuration
eureka.client.serviceUrl.defaultZone=http://192.168.1.55:8761/eureka/
Add test class
@RestController
public class TestController {
@Autowired
private TestClient client;
@GetMapping("/test")
public String test() {
String result = client.hello();
return result;
}
}
test , Test success

边栏推荐
- Hydrogen entrepreneurship competition | Liu Yafang, deputy director of the science and Technology Department of the National Energy Administration: building a high-quality innovation system is the cor
- 苹果供应链十年浮沉:洋班主任和它的中国学生们
- Data transmission under the same LAN based on tcp/ip
- 【GCN-RS】Towards Representation Alignment and Uniformity in Collaborative Filtering (KDD‘22)
- 【GCN-RS】Are Graph Augmentations Necessary? Simple Graph Contrastive Learning for RS (SIGIR‘22)
- [cloud co creation] what is the role of AI in mathematics? What will be the disruptive impact on the mathematical world in the future?
- JS 面试题:手写节流(throttle)函数
- Video caption (cross modal video summary / subtitle generation)
- Ansible
- Plus版SBOM:流水线物料清单PBOM
猜你喜欢

【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)

Multi-Label Image Classification(多标签图像分类)

Atomic atomic class

【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)

Go garbage collector Guide

Zuul网关使用

【GCN-CTR】DC-GNN: Decoupled GNN for Improving and Accelerating Large-Scale E-commerce Retrieval WWW22

异构图神经网络用于推荐系统问题(ACKRec,HFGN)

Musk's "eternal soul": half hype, half flicker

Zero shot image retrieval (zero sample cross modal retrieval)
随机推荐
【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
Atomic 原子类
scrapy 设置随机的user_agent
Transformer变体(Routing Transformer,Linformer,Big Bird)
I advise those students who have just joined the work: if you want to enter the big factory, you must master these concurrent programming knowledge! Complete learning route!! (recommended Collection)
面试官:“同学,你做过真实落地项目吗?”
Figure neural network for recommending system problems (imp-gcn, lr-gcn)
From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"
flink sql client 连接mysql报错异常,如何解决?
剑指 Offer 22. 链表中倒数第k个节点
selenium使用———安装、测试
氢能创业大赛 | 国家能源局科技司副司长刘亚芳:构建高质量创新体系是我国氢能产业发展的核心
苹果供应链十年浮沉:洋班主任和它的中国学生们
【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021
Multi label image classification
【AI4Code最终章】AlphaCode:《Competition-Level Code Generation with AlphaCode》(DeepMind)
Application and innovation of low code technology in logistics management
【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
利用wireshark对TCP抓包分析
【GCN-CTR】DC-GNN: Decoupled GNN for Improving and Accelerating Large-Scale E-commerce Retrieval WWW22