0

Spring Cloud の Open Feign を使用して別のサービスを呼び出そうとしていますが、次のような応答が得られます。

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

OkHttp クライアントを使用するように Feign を構成しましたが、それがエラーの原因であるかどうかはわかりません。

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

2 に答える 2

1

Finchey.SR1 を使用している場合は、これを確認できます https://stackoverflow.com/a/52727544 そのクラウド バージョンの ContentPath に問題があるようです。

于 2020-08-30T18:20:57.563 に答える