mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
升级rocketmq到4.8.0,并且支持环境变量优先配置 (#3450)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.alibaba.otter.canal.common.utils;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class PropertiesUtils {
|
||||
public static String getProperty(Properties properties, String key, String defaultValue) {
|
||||
String value = getProperty(properties, key);
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getProperty(Properties properties, String key) {
|
||||
key = StringUtils.trim(key);
|
||||
String value = System.getProperty(key);
|
||||
|
||||
if (value == null) {
|
||||
value = System.getenv(key);
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
value = properties.getProperty(key);
|
||||
}
|
||||
|
||||
return StringUtils.trim(value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user