请问一下,有人遇到过feign调用,然后返回null的吗?

困扰两天了,没搞清楚究竟是干嘛了

@FeignClient(value = "datameta", url = "http://xxxx/")
public interface RemoveDataSourceCaller {

    /**
     * 获取集群组件信息
     *
     * @return
     */
    @RequestMapping(value = "/xxxxx", method = RequestMethod.POST, produces = {
            "application/json;charset=UTF-8"
    })
    ResponseU getxxxxx();
}

然后我在一个接口调用

ResponseU clusterListInfo = removeDataSourceCaller.getxxxxx();

每次debug返回的clusterListInfo都是null,有人遇到过吗,原因我想不出来究竟是什么,百度有人说要加注解,但注解是有的,我这里又没参数,没看明白

阅读 7.6k
1 个回答

自己试了2小时,我也是刚在学习springcloud, 我发现没打断点的情况下是正常返回, 打了断点没走完,过了一会就马上响应了,最后发现是启用了熔断器的熔断超时响应了,默认是1秒, 配置上熔断器超时和调用超时就好了:

hystrix:
command:

default:
  execution:
    timeout:
      enabled: true
    isolation:
      thread:
        timeoutInMilliseconds: 6000

ribbon:
ConnectTimeout: 5000
ReadTimeout: 50000

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题