OpenFeign快速开始
1、pom.xml加入
<!-- openfeign --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency>
2、启动类增加注解
@EnableFeignClients
3、创建接口类
@FeignClient(name = "stock", path = "/stock")
public interface StockFeignService {
@RequestMapping("deduct")
String deduct();
}
4、引入并调用接口
@Autowired private StockFeignService stockFeignService; @RequestMapping("add") public String add(){ System.out.println("下单成功!"); String msg = stockFeignService.deduct(); System.out.println(msg); return "hello world"; }

浙公网安备 33010602011771号