Spring Cloud SPIRNG Integrated feign

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.