Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 917 Bytes

Spring-SystemPropertyPlaceholderResolver.md

File metadata and controls

34 lines (28 loc) · 917 Bytes

Spring SystemPropertyPlaceholderResolver

  • 类全路径: org.springframework.util.SystemPropertyUtils.SystemPropertyPlaceholderResolver
	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;
			}
		}
	}