只调用端处理:
1.依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
2.启动
添加注解
@EnableDiscoveryClient
@EnableFeignClients
3.代码
@FeignClient("base")
public interface BaseClient {
@GetMapping("/label/{id}")
public Result findById(@PathVariable("id") String id);
}
4.测试
@Autowired
private BaseClient baseClient;
@GetMapping("/label/{id}")
public Result findByLabelId(@PathVariable("id") String id) {
return baseClient.findById(id);
}
请求从接口,会调用base微服务的接口