SpringCloud 简化微服务调用 Feign
-
maven 依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>3.0.6</version>
</dependency>
-
启动类增加注解
- @EnableFeignClients:开启feign调用功能
-
建立远程调用接口
/**
* 样例集成远程接口
*/
@FeignClient(name = "com-demo",contextId = "testDemoService")
public interface DemoService {
/**
*
* @param requestBody
* @param authorization
* @return
*/
@GetMapping("/api/demo/dispatch/demos")
AjaxResponse demosByPage(