首页 > 编程语言 > 详细

springcloud--feign

时间:2020-02-16 21:55:54      阅读:66      评论:0      收藏:0      [点我收藏+]

 

feign

服务与服务之间的调用方式

 

技术分享图片

 

@FeignClient("stores")
public interface StoreClient {
    @RequestMapping(method = RequestMethod.GET, value = "/stores")
    List<Store> getStores();

    @RequestMapping(method = RequestMethod.POST, value = "/stores/{storeId}", consumes = "application/json")
    Store update(@PathVariable("storeId") Long storeId, Store store);
}

 

依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

 

@EnableEurekaClient
@SpringBootApplication
@EnableFeignClients(clients = StudentService.class) //指定API开启
public class MyribbonApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyribbonApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}

 

springcloud--feign

原文:https://www.cnblogs.com/jentary/p/12318119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!