Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java faign不解析名称_Java_Spring_Spring Boot_Spring Cloud_Openfeign - Fatal编程技术网

Java faign不解析名称

Java faign不解析名称,java,spring,spring-boot,spring-cloud,openfeign,Java,Spring,Spring Boot,Spring Cloud,Openfeign,我正在尝试使用Spring Cloud的Open Faign调用另一个服务,但我一直得到以下回应: { "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": "/a

我正在尝试使用Spring Cloud的Open Faign调用另一个服务,但我一直得到以下回应:

{
  "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"
}
这是我的密码:

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);
}

可能是因为您尚未指定基本URL。对于客户端&它使用基本URL作为身份验证服务

@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);
}

如果您使用的是Finchey.SR1,可以检查此项
该云版本中的ContentPath似乎存在问题。

您是否在属性文件中添加了eureka.instance.hostname=您是否使用类似于eurkea或concur的发现客户端?@Spencergib我正在使用EurekaDo您在类路径上有功能区?你用的是什么版本?@Spencergib。我在类路径上没有Ribbon。我正在使用Finchley.SR1版本。是否需要基本url?服务名称应该足够了,因为它在本地工作。
@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);
}