From 875ccfdbbd84f2f27289e8af4b2b18dd06ff59e2 Mon Sep 17 00:00:00 2001 From: wangwei10061 <153692771@qq.com> Date: Wed, 25 Apr 2018 10:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E7=8E=AF=E5=A2=83=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E4=BD=BF=E7=94=A8=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 9 +++++- .../bridge/common/settings/AppConfig.java | 2 +- .../bridge/common/utils/RedisPool.java | 3 +- ...roperties => config_production.properties} | 0 ...properties.test => config_test.properties} | 0 .../{logback.xml => logback_production.xml} | 4 +-- src/main/resources/logback_test.xml | 29 +++++++++++++++++++ src/main/webapp/WEB-INF/web.xml | 2 +- 8 files changed, 43 insertions(+), 6 deletions(-) rename src/main/resources/{config.properties => config_production.properties} (100%) rename src/main/resources/{config.properties.test => config_test.properties} (100%) rename src/main/resources/{logback.xml => logback_production.xml} (92%) create mode 100644 src/main/resources/logback_test.xml diff --git a/readme.md b/readme.md index aa12589..bb2435d 100644 --- a/readme.md +++ b/readme.md @@ -40,4 +40,11 @@ webssh 和 评测的pod分别放到不同的namespace下 **pod命名规则** 1. 评测:environment-tpi 2. webssh: webssh-environment-tpi -3. webssh+评测: evassh-environment-tpi \ No newline at end of file +3. webssh+评测: evassh-environment-tpi + +**多profile配置** +在tomcat/bin目录下的setenv.sh文件中设置了启动时使用的profile, +如: `-Dspring.profiles.active=test` + +**日志** +正式版按天生成,测试版记入catalina.out文件中 \ No newline at end of file diff --git a/src/main/java/com/educoder/bridge/common/settings/AppConfig.java b/src/main/java/com/educoder/bridge/common/settings/AppConfig.java index 33a30c9..d2a8cff 100644 --- a/src/main/java/com/educoder/bridge/common/settings/AppConfig.java +++ b/src/main/java/com/educoder/bridge/common/settings/AppConfig.java @@ -8,7 +8,7 @@ import org.springframework.context.annotation.PropertySource; * Created by guange on 18/02/2017. */ @Configuration("AppConfig") -@PropertySource("classpath:config.properties") +@PropertySource("classpath:config_${spring.profiles.active}.properties") public class AppConfig { @Value("${educoderURL}") diff --git a/src/main/java/com/educoder/bridge/common/utils/RedisPool.java b/src/main/java/com/educoder/bridge/common/utils/RedisPool.java index 6f37da5..129da39 100644 --- a/src/main/java/com/educoder/bridge/common/utils/RedisPool.java +++ b/src/main/java/com/educoder/bridge/common/utils/RedisPool.java @@ -30,7 +30,8 @@ public final class RedisPool { static { try { Properties prop = new Properties(); - prop.load(RedisPool.class.getClassLoader().getResourceAsStream("config.properties")); + String active = System.getProperty("spring.profiles.active"); + prop.load(RedisPool.class.getClassLoader().getResourceAsStream("config_" + active + ".properties")); String ADDR = prop.getProperty("redisAddress"); int PORT = Integer.parseInt(prop.getProperty("redisPort")); diff --git a/src/main/resources/config.properties b/src/main/resources/config_production.properties similarity index 100% rename from src/main/resources/config.properties rename to src/main/resources/config_production.properties diff --git a/src/main/resources/config.properties.test b/src/main/resources/config_test.properties similarity index 100% rename from src/main/resources/config.properties.test rename to src/main/resources/config_test.properties diff --git a/src/main/resources/logback.xml b/src/main/resources/logback_production.xml similarity index 92% rename from src/main/resources/logback.xml rename to src/main/resources/logback_production.xml index d87d79d..d65ddbc 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback_production.xml @@ -7,7 +7,7 @@ %d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n - DEBUG + INFO ${log_path}bridge.%d{yyyy-MM-dd}.log @@ -23,7 +23,7 @@ - + diff --git a/src/main/resources/logback_test.xml b/src/main/resources/logback_test.xml new file mode 100644 index 0000000..78a9011 --- /dev/null +++ b/src/main/resources/logback_test.xml @@ -0,0 +1,29 @@ + + + + + + + %d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n + + + + DEBUG + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index e6741fa..01c9084 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -21,7 +21,7 @@ logbackConfigLocation - classpath:logback.xml + classpath:logback_${spring.profiles.active}.xml