Restserver
@RestControllerpublic class Policecontroller {@RequestMapping (value = "/call/{id}", method = Requestmethod.get, produces = mediatype.application_json_value) public Police call (@PathVariable Integer ID, httpservletrequest request) { Police p = new Police ();p. SetId (ID);p. SetName ("Angus");p. Setmessage (Request.getrequesturl (). toString ()); return p;} @RequestMapping (value = "/hello/{name}", method = requestmethod.get) public String Hello (@PathVariable string name) { Return "Hello," + name;} @RequestMapping (value = "/hellowd", method = requestmethod.get) public String Hellowithoutarg () {return ' Hello World ';}}
Feign Client interface
@FeignClient ("Spring-feign-provider") public interface Helloclient {@RequestMapping (method = Requestmethod.get, value = "/hello/{name}") String Hello (@PathVariable ("name") string name); @RequestMapping (method = Requestmethod.get, value= ") /call/{id} ") Police Getpolice (@PathVariable (" id ") Integer ID), @MyUrl (url ="/hellowd ", method =" GET ") String MyHello ();}
Feign client
@RestControllerpublic class TestController {@Autowiredprivate helloclient helloclient; @RequestMapping (method = Requestmethod.get, value= "/router") public String router () {string result = Helloclient.hello ("Angus"); return result;} @RequestMapping (method = Requestmethod.get, value= "/police", produces = mediatype.application_json_value) public Police Getpolice () {Police p = helloclient.getpolice (1); return p;} @RequestMapping (method = Requestmethod.get, value= "/myhello") public String Myhello () {return Helloclient.myhello ();}}
Spring Cloud SPIRNG Integrated feign