You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
918 B
35 lines
918 B
# Spring SystemPropertyPlaceholderResolver
|
|
|
|
- 类全路径: `org.springframework.util.SystemPropertyUtils.SystemPropertyPlaceholderResolver`
|
|
|
|
|
|
```java
|
|
private static class SystemPropertyPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver {
|
|
|
|
private final String text;
|
|
|
|
public SystemPropertyPlaceholderResolver(String text) {
|
|
this.text = text;
|
|
}
|
|
|
|
@Override
|
|
@Nullable
|
|
public String resolvePlaceholder(String placeholderName) {
|
|
try {
|
|
String propVal = System.getProperty(placeholderName);
|
|
if (propVal == null) {
|
|
// Fall back to searching the system environment.
|
|
// 获取系统属性
|
|
propVal = System.getenv(placeholderName);
|
|
}
|
|
return propVal;
|
|
}
|
|
catch (Throwable ex) {
|
|
System.err.println("Could not resolve placeholder '" + placeholderName + "' in [" +
|
|
this.text + "] as system property: " + ex);
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
``` |