首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Feign不解析名称

Feign不解析名称
EN

Stack Overflow用户
提问于 2020-01-14 23:30:23
回答 2查看 1.4K关注 0票数 0

我正在尝试使用Spring Cloud的Open Feign调用另一个服务,但以下是我不断得到的响应:

代码语言:javascript
复制
{
  "timestamp": 1579015052962,
  "status": 500,
  "error": "Internal Server Error",
  "message": "auth-service: Name or service not known executing GET http://auth-service/api/v1/auth",
  "path": "/api/v1/event"
}

下面是我的代码:

代码语言:javascript
复制
package com.eventmanager.events.client;

import com.eventmanager.events.client.mappings.Auth;
import com.eventmanager.events.config.CustomFeignClientConfig;
import com.eventmanager.events.responses.Response;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;

@FeignClient(name = "auth-service", configuration = CustomFeignClientConfig.class)
public interface AuthClient {
  @GetMapping("/api/v1/auth")
  public Response<Auth> getLoggedUser(@RequestHeader(value = "Authorization") String authorization);
}

我将Feign配置为使用OkHttp客户端,但我不确定是不是它导致了这个错误:

代码语言:javascript
复制
package com.eventmanager.events.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import feign.okhttp.OkHttpClient;

@Configuration
public class CustomFeignClientConfig {
  @Bean
  public OkHttpClient client() {
    return new OkHttpClient();
  }
}
EN

回答 2

Stack Overflow用户

发布于 2020-08-31 02:20:58

如果你正在使用Finchey.SR1,你可以检查这个https://stackoverflow.com/a/52727544在那个云版本中的ContentPath似乎有一个问题。

票数 1
EN

Stack Overflow用户

发布于 2020-01-15 00:46:55

可能是因为您尚未指定基URL。对于客户端&它将基本URL作为auth-service。

代码语言:javascript
复制
@FeignClient(name = "auth-service", configuration = CustomFeignClientConfig.class, url = "http://lcoalhost:8080")
public interface AuthClient {
  @GetMapping("/api/v1/auth")
  public Response<Auth> getLoggedUser(@RequestHeader(value = "Authorization") String authorization);
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59736964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档