From 59d36ce4853ce69f6760a197603dd6ca5cd1387e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=9C=EC=98=A8=ED=8C=8C=ED=8C=8C?= Date: Mon, 7 Mar 2022 01:40:13 +0900 Subject: [PATCH] =?UTF-8?q?yaml=20=ED=8C=8C=EC=9D=BC=20local/prod=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/ci/AppCiApplication.java | 20 +++++++++++++--- .../ci/api/presentation/NiceCiController.java | 4 ++-- src/main/resources/application-local.yml | 24 +++++++++++++++++++ src/main/resources/application-prod.yml | 24 +++++++++++++++++++ src/main/resources/application.yml | 17 ++++--------- 5 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/application-local.yml create mode 100644 src/main/resources/application-prod.yml diff --git a/src/main/java/cokr/xit/ci/AppCiApplication.java b/src/main/java/cokr/xit/ci/AppCiApplication.java index f18f20a..5c91ffb 100644 --- a/src/main/java/cokr/xit/ci/AppCiApplication.java +++ b/src/main/java/cokr/xit/ci/AppCiApplication.java @@ -1,14 +1,21 @@ package cokr.xit.ci; +import jdk.internal.module.Checks; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.ApplicationPidFileWriter; +import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.context.annotation.ComponentScan; +import java.util.Optional; + @Slf4j @ComponentScan(basePackages = "cokr.xit") @SpringBootApplication +@ServletComponentScan public class AppCiApplication { public static void main(String[] args) { @@ -16,21 +23,28 @@ public class AppCiApplication { Long begin = System.currentTimeMillis(); log.info("CI Application load start..."); + if(!Optional.ofNullable(System.getProperty("spring.profiles.active")).isPresent()) { + log.error("===================================================================="); + log.error(">>>>>>>>>>>>>> Undefined start option <<<<<<<<<<<<<<"); + log.error(">>>>>>>>>>>>>> -Dspring.profiles.active=local|prod <<<<<<<<<<<<<<"); + log.error("============== ENS Application start fail ==============="); + log.error("===================================================================="); + System.exit(-1); + } SpringApplication application = new SpringApplication(AppCiApplication.class); application.addListeners(new ApplicationPidFileWriter()); //PID(Process ID 작성) application.run(args); - log.info("========================================================================================="); + log.info("============================================================================"); log.info("========== CI Application load Complete :: active profiles - {} ==========", System.getProperty("spring.profiles.active")); - log.info("========================================================================================="); + log.info("============================================================================"); Long end = System.currentTimeMillis(); System.out.println("===================================================="); System.out.println("기동 소요시간: "+ (end-begin) +"ms"); System.out.println("===================================================="); - } } diff --git a/src/main/java/cokr/xit/ci/api/presentation/NiceCiController.java b/src/main/java/cokr/xit/ci/api/presentation/NiceCiController.java index 97d8a58..7df093e 100644 --- a/src/main/java/cokr/xit/ci/api/presentation/NiceCiController.java +++ b/src/main/java/cokr/xit/ci/api/presentation/NiceCiController.java @@ -22,9 +22,9 @@ public class NiceCiController { private final NiceCiService diCiService; - @Value("${nice.api.ci.site-code}") + @Value("${nice.api.ci.site-code ?: }") private String SITE_CODE; - @Value("${nice.api.ci.site-pw}") + @Value("${nice.api.ci.site-pw ?: }") private String SITE_PW; @SuppressWarnings("deprecation") diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml new file mode 100644 index 0000000..c8c6ab8 --- /dev/null +++ b/src/main/resources/application-local.yml @@ -0,0 +1,24 @@ +# ===================================================== +# Server 설정 +# ===================================================== +server: + port: 8080 + + +# ===================================================== +# Spring 설정 +# ===================================================== +spring: + config: + activate: + on-profile: local + + +# ===================================================== +# NICE api 계약정보 +# ===================================================== +nice: + api: + ci: + site-code: + site-pw: diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..e193039 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,24 @@ +# ===================================================== +# Server 설정 +# ===================================================== +server: + port: 8080 + + +# ===================================================== +# Spring 설정 +# ===================================================== +spring: + config: + activate: + on-profile: prod + + +# ===================================================== +# NICE api 계약정보 +# ===================================================== +nice: + api: + ci: + site-code: + site-pw: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e61427f..709a98b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,7 +1,9 @@ - +# ===================================================== +# Spring 설정 +# ===================================================== spring: profiles: - active: prod + active: local mvc: view: prefix: /WEB-INF/jsp/ @@ -11,7 +13,7 @@ spring: enabled: true pid: file: app-ci.pid - + # ===================================================== # Logging 설정 # ===================================================== @@ -28,12 +30,3 @@ logging: root: info '[org.hibernate.sql]': info - -# ===================================================== -# NICE api 계약정보 -# ===================================================== -nice: - api: - ci: - site-code: - site-pw: