Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Ali Development case: Spring Could--nacos Service Registration and Discovery Integration feign

Shulou Source: shulou.com Published: 2022-06-03 06:06:05 11月23日 Update

Preface

Some time ago, the owner specially introduced Feign to call Xiao Huang Tu API, which is obviously not the most elegant way to use it. But for most small and medium-sized companies, the service has been torn down so much that it can basically meet the demand. You can rely on both breakers and clusters.

Here is the simplest example to share with you.

module

Spring-Boot 2.2.0.RELEASE

Spring-Cloud Greenwich.SR3

Spring-Cloud-Alibaba 2.1.0.RELEASE

Nacos registry

Feign HTTP client

To be clear, Spring Cloud Alibaba graduated successfully on August 1, 2019 and officially listed in Spring. The latest version after successful listing is 2.1.0.

Main project

Server side

Application.properties configuration:

Simple service provider interface:

Client

Application.properties configuration:

Configure the client call interface:

Client invocation example:

Test service

Start feign-server and feign-client respectively, and then log in to the Nacos console. If the following two services appear, the configuration is successful.

If the client accesses localhost:8081/getMessage and comes back to flirt with me, it means the call is successful.

Summary

Finally, there is welfare time, there is a need for source code partners can read the original text pull, in order to facilitate debugging, there is also built-in free Nacos registration center.

Tags: Service customer client configuration success interface time elegance two small and medium example company preface original text most official partner summary console Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL Apple Docker OPPO Reno