Spring Cloud Feign 1 (declarative service invocation feign introduction)

Source: Internet
Author: User

Spring Cloud feign, based on Netflix feign, also integrates the Spring Cloud ribbon and Spring Cloud Hytrix, which provides a declarative approach to Web service client definition in addition to the power of both.

In the ribbon example, we tried to use Resttemplate to implement an interface call to a dependent service, and Spring Cloud feign was encapsulated on that basis to help us define and implement the definition of a dependent service interface.

First create a new project named Feign-consumer to introduce Eureka and feign dependencies

The main class opens the Feign support function by adding @enablefeignclients annotations

Define HelloService to bind services by specifying a service name through @feignclient ("Hello-service") annotations

Then use SPRINGMVC annotations to bind specific rest interfaces provided by the service

Then create a consumercontroller to implement the call to the feign client

The application.properties is configured as follows

Spring.application.name=feign-consumer
server.port=9002
Eureka.client.serviceurl.defaultzone=http://peer1:1111/eureka/,http://peer2:1112/eureka

Start the project test with the same effect as the Ribbon client load

The service invocation is implemented gracefully and simply by spring Cloud feign in a declarative manner.

Spring Cloud Feign 1 (declarative service invocation feign introduction)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.