In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to implement the interface call of FeignClient, which has a certain reference value. Interested friends can refer to it. I hope you will learn a lot after reading this article.
FeignClient API call
No parameter
String parameter
Object parameter
Draw up the client side to call the server interface, directly put the code, reference format.
1. No parameter
Server method:
/ * Test, get the simple text * / @ GetMapping ("/ info") public String info () {return "zero";}
Client method:
/ * * API test * / @ GetMapping (value = "/ info") public String getInfo (); 2. String parameter
Server method:
@ ResponseBody @ PostMapping (value = "/ test") public String test (String s) {return s;}
Client method:
@ RequestMapping (value = "/ test", method = RequestMethod.POST) String test (@ RequestParam (value = "s") String s); 3. Object parameters
Server method:
@ PostMapping (value = "/ company/list") public List companyList (@ RequestBody CruiseCompInfo cruiseCompInfo) {return cruiseCompInfoService.selectCruiseCompInfoList (cruiseCompInfo);}
Client method:
@ RequestMapping (value = "/ company/list", method = RequestMethod.POST) public List companyList (@ RequestBody CruiseCompInfo cruiseCompInfo); bug service receiver interface encountered by feign interface parameters
As follows:
When the service invokes the calling service, the caller passes the parameters, but all the properties in the parameter object in the receiver interface are empty.
Solution
As follows:
First attempt:
All attributes are appended with @ JsonProperty (value= attribute name), which is invalid.
Second attempt:
All attributes are appended with @ JsonProperty (the first letter of the value= attribute name is capitalized), which is invalid
Third attempt:
Do not add @ JsonProperty annotation to attributes that do not pass values.
Thank you for reading this article carefully. I hope the article "how to implement FeignClient Interface call" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.