From ebccd7369723067d7b1f58f0f9e823390cba2b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=84=EC=A2=85=EB=AF=BC?= Date: Sun, 14 Jan 2024 12:54:44 +0900 Subject: [PATCH] [FIX] yml --- .../dailyon/auctionservice/config/WebClientConfig.java | 8 +++++--- src/main/resources/application-dev.yml | 5 ++++- src/main/resources/application-local.yml | 2 +- src/main/resources/application-prod.yml | 5 ++++- src/test/resources/application.yml | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/dailyon/auctionservice/config/WebClientConfig.java b/src/main/java/com/dailyon/auctionservice/config/WebClientConfig.java index 6c2bc85..6d59325 100644 --- a/src/main/java/com/dailyon/auctionservice/config/WebClientConfig.java +++ b/src/main/java/com/dailyon/auctionservice/config/WebClientConfig.java @@ -1,21 +1,23 @@ package com.dailyon.auctionservice.config; +import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.web.reactive.function.client.WebClient; @Configuration +@RequiredArgsConstructor public class WebClientConfig { - @Value("${endpoint.product-service}") - private String endpoint; + private final Environment env; @Bean public WebClient webClient() { return WebClient.builder() - .baseUrl(endpoint) + .baseUrl(env.getProperty("endpoint.product-service")) .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(2 * 1024 *1024)) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .build(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index ee0f0bd..72f4267 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -23,4 +23,7 @@ eureka: instance-id: ${spring.application.name}:${server.port} # 기본적으로 유레카는 '호스트 이름'으로 접속하는 서비스를 레지스트리에 등록 -> 로컬(localhost) # 따라서 쿠버네티스, 도커와 같이 임의의 호스트 이름을 가지는 경우는 false로 하면 클라이언트를 인식하지 못한다. - prefer-ip-address: true \ No newline at end of file + prefer-ip-address: true + +endpoint: + product-service: http://localhost:8085 \ No newline at end of file diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index c70aad2..69e2974 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -40,7 +40,7 @@ eureka: instance-id: ${spring.cloud.client.hostname}:${spring.application.instance_id:${random.value}} endpoint: - product-service: localhost:8085 + product-service: http://localhost:8085 cloud: aws: diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index eed9852..2918efc 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -27,4 +27,7 @@ eureka: instance-id: ${spring.application.name}:${server.port} # 기본적으로 유레카는 '호스트 이름'으로 접속하는 서비스를 레지스트리에 등록 -> 로컬(localhost) # 따라서 쿠버네티스, 도커와 같이 임의의 호스트 이름을 가지는 경우는 false로 하면 클라이언트를 인식하지 못한다. - prefer-ip-address: true \ No newline at end of file + prefer-ip-address: true + +endpoint: + product-service: http://product-service:8085 \ No newline at end of file diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 85a436c..ca27812 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -17,4 +17,4 @@ logging: root: DEBUG endpoint: - product-service: localhost:8085 + product-service: http://localhost:8085