A Preliminary Study of Spring (4) feign

1. To create a project, please refer to the demo project. The services to be accessed need to be registered with erueka. Feign itself needs to be registered with erueka
. 2. Add
<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring- cloud-starter-feign</artifactId>
   <version>1.3.2.RELEASE</version>
</dependency>
3. Add the @EnableFeignClients annotation to the startup type to start the FeignClient functional
  interface class Add: @FeignClient(name="service name ", url="url") For example: @FeignClient(name="demo-config-client", url="127.0.0.1:5555")
  Add to the interface class method: @RequestMapping(value = "/con/hello" , method = RequestMethod.POST)
4. Configure the application.porperties property.
feign.httpclient.enabled=true
5. Start, the program is successful.
git address: https://github.com/leaf-it/demo-feign

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326214140&siteId=291194637
Recommended