Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the problem of multiple consumers repeatedly defining feign client based on spring cloud

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "how to understand the problem of repeatedly defining feign client based on spring cloud". In daily operation, I believe many people have doubts about how to understand the problem of repeated definition of feign client based on spring cloud. The editor consulted all kinds of materials and sorted out a simple and useful method of operation. I hope it will be helpful to answer the question of "how to understand the repeated definition of feign client based on multiple consumers of spring cloud"! Next, please follow the editor to study!

Catalogue

Multiple consumers of springcloud repeatedly define feign client

Report an error in spring cloud+feignClient

Multiple consumers of springcloud repeatedly define feign client

The spring cloud consumer invokes the service provider in two ways. Rest+ribbon and Feign,Feign are a declarative pseudo-Http client that is easier to use, so our project chooses Feign as the service communication method.

There are six modules in the project, which are called A, B, D, D, E, F, C, D, D, and F, which are indispensable to each other before the module.

Here's the problem. To invoke the server through FeignClient, you need to establish a FeignClient interface for the invocation of the server at the consumer side.

If both An and B need to call C.

A call C needs to establish a C FeignClient interface in A module.

B calls C also needs to establish a C FeignClient interface in B module.

If D, E, and F all need to use the C module, then you need to set up three more FeignClient. And the code in these FeignClient is all the same.

In that case, can the FeignClient interface be defined as a general interface?

The author tries to set up a separate module G for FeignClient, and manages the FeignClient call interface of each module in module G. when the modules of pom are modulated by each other, only G module is needed.

The idea was beautiful, the reality was cruel, and the experimental results failed.

After introducing module G, start SpringBoot and control the error report. Bean not found.

Consumer startup class Application with scan package annotation @ ComponentScan (basePackages= {"com.chelizi.feign.intf"})

* *

APPLICATION FAILED TO START

* *

Description:

A component required a bean of type 'com.chelizi.feign.intf.system.SysSerialNumberController' that could not be found.

Action:

Consider defining a bean of type 'com.chelizi.feign.intf.system.SysSerialNumberController' in your configuration.

With the @ ComponentScan annotation above, the normal @ Component or @ Service JavaBean under com.chelizi.feign.intf can be scanned, but the @ FeignClient class cannot be scanned.

Report an error in spring cloud+feignClient

Consider defining a bean of type 'xxxx' in your configuration error occurred in spring cloud+feignClient

Most of the main reason is that it is not enabled.

At this point, the study on "how to understand the problem of repeatedly defining feign client based on multiple consumers of spring cloud" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 296

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report