In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to solve the version problem of Feignclient call in Springboot", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to solve the version problem of Feignclient call in Springboot".
There are three Springboot projects, namely jpmc-adapter, gsdic-api and twpre-api. Gsdic-api and twpre-api are public services that provide the API of Restful and are called through feign client.
The big background is
Jpmc-adapter now needs to invoke two other public services.
Springboot version:
Jpmc-adapter 1.5.9
Gsdic-api 1.5.9
Twpre-api 2.0.5
You can see that the Springboot versions of jpmc-adaper and gsdic-api are the same. If jpmc-adaper simply calls gsdic-api through feign client, everything is OK!
The situation now is that jpmc-adaper needs to call both gsdic-api and twpre-api, and then reports an error when starting the project
The error is as follows
This is a problem caused by inconsistent versions of Springboot.
Let's first look at how the other two services are invoked in jpmc-adaper.
It is roughly as follows:
1. Introduce jar packages for two other public services into build.gradle.
2. Unified management depends on the version number in gradle.properties, as follows:
3. Start the configuration of the public service introduced into the class:
4. The call in the test class is as follows:
The FeignClient of twpre-api is from org.springframework.cloud.openfeign.FeignClient; as follows:
The FeignClient of gsdic-api comes from org.springframework.cloud.netflix.feign.FeignClient, as follows:
The solution is as follows
You can change the version of all services to be consistent, so that you can avoid such problems. However, changing versions may cause a lot of problems, which can be solved in the following ways:
Because the versions of jpmc-adapter and gsdic-api are the same, we override the FeignClient of twpre-api in the caller, that is, jpmc-adapter.
Package com.geoswift.jpmc.api; import org.springframework.cloud.netflix.feign.FeignClient; import com.geoswift.twpre.fapi.TwpreRestAPI; @ FeignClient (name= "twpre", path= "/ api/twpre/v1") public interface MyTwpreRestAPI extends TwpreRestAPI {}
Then use our rewritten client during the test, as follows:
The above is all the content of the article "how to solve the version problem of Feignclient call in Springboot". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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: 0
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.