Get the App
SLTechnology News&Howtos  ›  Development  › 

The method of multi-parameter transmission in SpringCloud Feign and what problems need to be paid attention to

Shulou Source: shulou.com Published: 2022-06-01 05:54:00 11月09日 Update

In this article Xiaobian for you to introduce in detail the "SpringCloud Feign multi-parameter transmission methods and need to pay attention to what problems", detailed content, clear steps, details handled properly, I hope that this "SpringCloud Feign multi-parameter transmission methods and need to pay attention to what problems" article can help you solve doubts, the following with the editor's ideas slowly in-depth, together to learn new knowledge.

Multi-parameter transfer of Feign and problems needing attention

The previous Eureka,Feign,Service is used here.

Add several methods in the service provider cloud-shop-userservice / * Save users * 18 / PostMapping ("/ user") public String aveUser (@ RequestBody User user) {logger.info ("Save users:" + user.toString ()); return "Success" } / * query users based on username and password * 18 / GetMapping ("/ findUser") public User findUserByNameAndPassword (String name, String password) {logger.info ("name:" + name + "--password:" + password); User user= new User () User.setName (name); user.setPassword (password); return user;} modify the UserService of feign and add the corresponding method package cn.sh.daniel.service; import org.springframework.cloud.netflix.feign.FeignClient;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.PostMapping Import org.springframework.web.bind.annotation.RequestBody;import cn.sh.daniel.entity.User; @ FeignClient (value = "cloud-shop-userservice") public interface UserService {@ GetMapping ("/ user/ {id}") public User findUserById (@ PathVariable ("id") Long id); @ PostMapping ("/ user/user") public String aveUser (@ RequestBody User user) @ GetMapping ("/ user/findUser") public User findUserByNameAndPassword (String name, String password);} call the method in the controller of feign / * Save user * January 18, 2018 * / @ PostMapping ("/ user") public String aveUser (@ RequestBody User user) {return userService.aveUser (user) } / * query the user based on user name and password * January 18, 2018 * / @ GetMapping ("/ findUser") public User findUserByNameAndPassword (String name, String password) {return userService.findUserByNameAndPassword (name, password);} restart the modified service to check whether the service registration is normal

During the startup process, you can find the Feign service startup error:

Tags: Cache time method success parameters user multiple number settable service problem data content article index query two median representative element Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info Redmi Shulou Technology NVidia