属性获取工具,支持从系统环境变量中获取参数

This commit is contained in:
thinkgem
2025-03-11 15:23:02 +08:00
parent fee4848ae2
commit a1beed5b5e

View File

@@ -174,7 +174,7 @@ public class PropertiesUtils {
private static final Pattern p1 = Pattern.compile("\\$\\{.*?\\}"); private static final Pattern p1 = Pattern.compile("\\$\\{.*?\\}");
/** /**
* 获取属性值取不到从System.getProperty()获取都取不到返回null * 获取属性值取不到从System.getProperty和System.getenv获取都取不到返回null
*/ */
public String getProperty(String key) { public String getProperty(String key) {
if (environment != null){ if (environment != null){
@@ -196,9 +196,10 @@ public class PropertiesUtils {
String systemProperty = System.getProperty(key); String systemProperty = System.getProperty(key);
if (systemProperty != null) { if (systemProperty != null) {
return systemProperty; return systemProperty;
}else{
return System.getenv(key);
} }
} }
return null;
} }
/** /**