多环境不同环境下使用不同配置文件
This commit is contained in:
parent
0e454011ef
commit
875ccfdbbd
|
@ -40,4 +40,11 @@ webssh 和 评测的pod分别放到不同的namespace下
|
||||||
**pod命名规则**
|
**pod命名规则**
|
||||||
1. 评测:environment-tpi
|
1. 评测:environment-tpi
|
||||||
2. webssh: webssh-environment-tpi
|
2. webssh: webssh-environment-tpi
|
||||||
3. webssh+评测: evassh-environment-tpi
|
3. webssh+评测: evassh-environment-tpi
|
||||||
|
|
||||||
|
**多profile配置**
|
||||||
|
在tomcat/bin目录下的setenv.sh文件中设置了启动时使用的profile,
|
||||||
|
如: `-Dspring.profiles.active=test`
|
||||||
|
|
||||||
|
**日志**
|
||||||
|
正式版按天生成,测试版记入catalina.out文件中
|
|
@ -8,7 +8,7 @@ import org.springframework.context.annotation.PropertySource;
|
||||||
* Created by guange on 18/02/2017.
|
* Created by guange on 18/02/2017.
|
||||||
*/
|
*/
|
||||||
@Configuration("AppConfig")
|
@Configuration("AppConfig")
|
||||||
@PropertySource("classpath:config.properties")
|
@PropertySource("classpath:config_${spring.profiles.active}.properties")
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
|
|
||||||
@Value("${educoderURL}")
|
@Value("${educoderURL}")
|
||||||
|
|
|
@ -30,7 +30,8 @@ public final class RedisPool {
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
Properties prop = new Properties();
|
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");
|
String ADDR = prop.getProperty("redisAddress");
|
||||||
int PORT = Integer.parseInt(prop.getProperty("redisPort"));
|
int PORT = Integer.parseInt(prop.getProperty("redisPort"));
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<pattern>%d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n</pattern>
|
<pattern>%d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
<level>DEBUG</level>
|
<level>INFO</level>
|
||||||
</filter>
|
</filter>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<fileNamePattern>${log_path}bridge.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log_path}bridge.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<looger name="com.spotify.docker.client" level="ERROR"/>
|
<looger name="com.spotify.docker.client" level="ERROR"/>
|
||||||
|
|
||||||
<root>
|
<root>
|
||||||
<level value="DEBUG"/>
|
<level value="INFO"/>
|
||||||
<appender-ref ref="bridge"/>
|
<appender-ref ref="bridge"/>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<!-- 打印在标准控制台 -->
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<!--格式化输出:%d:时间,%thread:线程名,%-5level:级别从左显示5个字符宽度,
|
||||||
|
%logger{50}:输出日志的类, 50代表包名加类名的总长度限制, %M 方法名 %L 行号 %msg:日志消息,%n是换行符-->
|
||||||
|
<pattern>%d{MM-dd HH:mm:ss} [%thread] %-5level -- %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>DEBUG</level>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 屏蔽框架输出 -->
|
||||||
|
<logger name="org.slf4j" level="ERROR"/>
|
||||||
|
<logger name="org.springframework" level="ERROR"/>
|
||||||
|
<logger name="io.swagger" level="ERROR"/>
|
||||||
|
<logger name="ch.qos.logback" level="OFF"/>
|
||||||
|
<logger name="springfox.documentation" level="ERROR"/>
|
||||||
|
<looger name="com.spotify.docker.client" level="ERROR"/>
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<level value="DEBUG"/>
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</configuration>
|
|
@ -21,7 +21,7 @@
|
||||||
<!-- logback -->
|
<!-- logback -->
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>logbackConfigLocation</param-name>
|
<param-name>logbackConfigLocation</param-name>
|
||||||
<param-value>classpath:logback.xml</param-value>
|
<param-value>classpath:logback_${spring.profiles.active}.xml</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<listener>
|
<listener>
|
||||||
|
|
Loading…
Reference in New Issue