spring cloud分布式项目中,提供fegin接口多个@FeignClient里面的name相同的问题

spring cloud分布式项目中,提供fegin接口多个@FeignClient里面的name相同的问题_第1张图片

如图,一个微服务中, 有多个FeignClient时

/**
 * @Author Ezio
 * @Date 2020/5/21 11:36
 */
@Component
@FeignClient(name = "hauto-merchant", contextId = "ClearClient", path = "clear", fallback = ClearHystrix.class)
public interface ClearClient {
    /**
     * 查询结算规则信息
     * @param commodityIds
     * @return
     */
    @PostMapping("queryRuleInfo")
    ResponseMessage queryClearRule(@RequestParam(value = "commodityIds",required = false) List commodityIds);

}




/**
 * @author miluo
 * @date 2020-05-26
 */
@Component
@FeignClient(name = "hauto-merchant", contextId = "CommodityClient", path = "commodity", fallback = CommodityHystrix.class)
public interface CommodityClient {

    /**
     * 获取商品公对公支付配置
     * @param param 查询参数
     * @return 查询结果
     */
    @RequestMapping("/noAuth/payConfig")
    ResponseMessage getCommodityPayConfig(@RequestBody CommodityNoAuthParam param);
}


/**
 * 自核信息操作feign接口
 * @Author Ezio
 * @Date 2020/5/19 15:42
 */
@Component
@FeignClient(name = "hauto-merchant", contextId = "ExamineClient", path = "examine", fallback = ExamineHystrix.class)
public interface ExamineClient {

    /**
     * 通过商品id获取自核账户
     * @param commodityId
     * @return
     */
    @PostMapping("getAccountByCommodityId")
    ResponseMessage getAccountByCommodityId(String commodityId);

}

需要用contextId来区分;

你可能感兴趣的:(微服务)