From 023d4ce0d2fd2a1cce46623fe08f84fa582dcb92 Mon Sep 17 00:00:00 2001 From: haerong22 Date: Thu, 16 Mar 2023 01:10:26 +0900 Subject: [PATCH] #35 springboot: application properties --- .../external/src/main/java/hello/EnvironmentCheck.java | 6 ++++-- .../external/src/main/resources/application-dev.properties | 3 +++ .../src/main/resources/application-prod.properties | 3 +++ .../external/src/main/resources/application.properties | 7 +++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 springboot/external/src/main/resources/application-dev.properties create mode 100644 springboot/external/src/main/resources/application-prod.properties diff --git a/springboot/external/src/main/java/hello/EnvironmentCheck.java b/springboot/external/src/main/java/hello/EnvironmentCheck.java index df53e344..8e63bbd6 100644 --- a/springboot/external/src/main/java/hello/EnvironmentCheck.java +++ b/springboot/external/src/main/java/hello/EnvironmentCheck.java @@ -16,10 +16,12 @@ public class EnvironmentCheck { @PostConstruct public void init() { String url = env.getProperty("url"); - String username = env.getProperty("username"); + String name = env.getProperty("name"); String password = env.getProperty("password"); + String testKey = env.getProperty("testKey"); log.info("env url={}", url); - log.info("env username={}", username); + log.info("env name={}", name); log.info("env password={}", password); + log.info("env testKey={}", testKey); } } diff --git a/springboot/external/src/main/resources/application-dev.properties b/springboot/external/src/main/resources/application-dev.properties new file mode 100644 index 00000000..580b36d7 --- /dev/null +++ b/springboot/external/src/main/resources/application-dev.properties @@ -0,0 +1,3 @@ +url=dev.db.com +name=dev_user +password=dev_pw \ No newline at end of file diff --git a/springboot/external/src/main/resources/application-prod.properties b/springboot/external/src/main/resources/application-prod.properties new file mode 100644 index 00000000..1b5a747c --- /dev/null +++ b/springboot/external/src/main/resources/application-prod.properties @@ -0,0 +1,3 @@ +url=prod.db.com +name=prod_user +password=prod_pw \ No newline at end of file diff --git a/springboot/external/src/main/resources/application.properties b/springboot/external/src/main/resources/application.properties index 8b137891..fbbbf31c 100644 --- a/springboot/external/src/main/resources/application.properties +++ b/springboot/external/src/main/resources/application.properties @@ -1 +1,8 @@ +testKey=local_value +#--- +spring.config.activate.on-profile=dev +testKey=dev_value +#--- +spring.config.activate.on-profile=prod +testKey=prod_value