zoukankan      html  css  js  c++  java
  • springcloud--feign

    feign

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

    feign默认是用ribbon,默认支持集群

    @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();
        }
    
    }
  • 相关阅读:
    第二次作业
    构造之法现代软件工程
    软件工程的作业五个问题!
    第四次作业
    第五次作业
    软件工程第二次作业
    第五次作业·
    第五次作业
    软件工程第二次作业
    软件工程第一次作业
  • 原文地址:https://www.cnblogs.com/jentary/p/12318119.html
Copyright © 2011-2022 走看看