zoukankan      html  css  js  c++  java
  • spring feign依赖包

    1.feign依赖包

    <properties>
            <java.version>1.8</java.version>
            <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
        </properties>
      <!-- 管理springboot相关依赖的版本例如:web,jdbc,test -->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.4.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    
    
        <dependencies>
         <!-- feign客户端依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-openfeign</artifactId>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>1.16.10</version>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <scope>test</scope>
            </dependency>
         <!-- feign使用服务id获取加请求路径获取的负载均衡依赖 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <groupId>com.github.jsonzou</groupId>
                <artifactId>jmockdata</artifactId>
                <version>4.1.1</version>
                <scope>test</scope>
            </dependency>
    
        </dependencies>
    <!-- 管理spring cloud依赖的版本,例如,feign,负载均衡的ribbon
    -->
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>${spring-cloud.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    <!-- eureka-client 包括了eureka客户端所有的依赖。
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
     -->
     

     2.Java类注释写法

    @SpringBootApplication
    @EnableDiscoveryClient
    @RestController
    @EnableFeignClients
    public class DemoApplication {
        @Autowired
        HelloClient client;
    
        @RequestMapping("/")
        public String hello() {
            return client.hello();
        }
    
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    
        @FeignClient("HelloServer")
        interface HelloClient {
            @RequestMapping(value = "/", method = GET)
            String hello();
        }
    }

    3.yml配置

    debug: true
    
    spring:
      application:
        name: nuts-warehouse-feign
    
    server:
      port: 8085
    
    eureka:
      client:
        serviceUrl:
          defaultZone: http://10.202.200.147:8081/eureka
  • 相关阅读:
    06--添加卡片到游戏
    05--创建卡片类
    04--帮助类ScreenAdapter编写
    03--重新规划程序结构
    02--2048实例搭建滑动框架
    iOS下的 Fixed + Input BUG现象
    textarea高度自适应自动展开
    margin负值问题
    audio元素和video元素在ios和andriod中无法自动播放
    js递归
  • 原文地址:https://www.cnblogs.com/z-test/p/10815384.html
Copyright © 2011-2022 走看看