SpringCloud Feign传对象参数调用失败的问题

  • 不支持GET请求方式
  • 使用Apache HttpClient替换Feign原生httpclient
  • @RequestBody接收json参数

bootstrap-local.yml

feign:
  httpclient:
    enabled: true

pom.xml



    com.netflix.feign
    feign-httpclient
    8.18.0


    org.apache.httpcomponents
    httpclient
    4.5.3

feignClient:

@FeignClient(name = "hd-ucenter-server", fallback = SysTestServerFallbackImpl.class)
public interface SysTestServer {

    @RequestMapping(value = "/test/test", method = RequestMethod.POST, consumes = "application/json")
    Object test(CurrentUser currentUser);

}

RestController:

@RestController
@PostMapping("/test")
public class TestController {

    @RequestMapping(value = "/test")
    public Object test(@RequestBody CurrentUser currentUser) {
        System.out.printf("调用test\n");
       return currentUser;
    }

}

 

 

 

你可能感兴趣的:(Java,SpringCloud)