zoukankan      html  css  js  c++  java
  • Spring Cloud Alibaba OpenFeign 契约配置

    package com.wsm.order.config;
    
    import feign.Contract;
    import feign.Logger;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    /**
     * 全局配置: 当使用@Configuration会将配置作用所有的报务提供方
     * 局部配置: 1 通过配置类:如果只针对个别服务进行配置,就不要加@Configuration
     *            2 通过配置文件
     */
    //@Configuration
    public class FeignConfig {
    
        @Bean
        public Logger.Level feignLoggerLevel(){
            return Logger.Level.FULL;
        }
    
    //    /**
    //     * 修改契约配置,支持Feign原生的注解
    //     * @return
    //     */
    //    @Bean
    //    public Contract feignContract(){
    //        return new Contract.Default();
    //    }
    
    }
    package com.wsm.order.feign;
    
    import feign.Param;
    import feign.RequestLine;
    import org.springframework.cloud.openfeign.FeignClient;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    @FeignClient(name = "product-service",path="/product")
    public interface ProductFeignService {
    
        @RequestLine("GET /{id}")
        public String get(@Param("id") Integer id);
    
    //    @RequestMapping("/{id}")
    //    public String get(@PathVariable("id") Integer id);
    }
    server:
      port: 8040
      #应用名称  (nacos 会将该名称当作服务名称)
    spring:
      application:
        name: order-openfeign-service
      cloud:
        nacos:
    #      server-addr: 127.0.0.1:8848
          server-addr: 192.168.133.128:8847  #集群 nginx 负载均衡访问 nacos
          discovery:
            username: nacos
            password: nacos
            namespace: public
    #springboot 默认的日志级别是info,feign的debug日志级别就不会输出
    logging:
      level:
    #    com.wsm.order.feign: debug
        com.wsm.order.feign.StockFeignService: debug
    # Feign 日志局部配置
    feign:
      client:
        config:
          product-service:
            loggerLevel: BASIC
            contract: feign.Contract.Default #设置为默认的契约 (还原成原生注解)

  • 相关阅读:
    chart控件多个ChartArea
    winform chart画折线,波形图,多条数据
    C# Chart 折线图 多条数据展示
    task一个任务结束后执行另一个操作
    C#多线程同步 读写锁ReaderWriterLock的用法
    C# 多线程文件读写整理总结
    vue解决跨域问题
    接前端页面
    使用vue+zrender绘制体温单 三测单(2)
    使用vue+zrender绘制体温单 三测单(1)
  • 原文地址:https://www.cnblogs.com/mingforyou/p/15522461.html
Copyright © 2011-2022 走看看