服务引用feign

2018-08-19  本文已影响0人  Nick_4438

前言

本文介绍如何使用fegin 调用服务。

操作步骤

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
@FeignClient(name = "product")
public interface ProductClient {
    @GetMapping("/msg") //访问product下面msg这个接口
    String productMsg();
}
public class ClientController {

    @Autowired
    private ProductClient productClient;

    @GetMapping("/getProductMsg")
    public String getProductMsg() {
        String response = productClient.productMsg();
        log.info("resoponse={}", response);
        return response;
    }
}

上一篇 下一篇

猜你喜欢

热点阅读