<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>PlaceholderResolver on 知识铺的博客</title>
    <link>https://index.zshipu.com/geek/tags/PlaceholderResolver/</link>
    <description>Recent content in PlaceholderResolver on 知识铺的博客</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh-CN</language>
    <lastBuildDate>Wed, 06 Mar 2024 12:35:00 +0000</lastBuildDate>
    <atom:link href="https://index.zshipu.com/geek/tags/PlaceholderResolver/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Spring-SystemPropertyPlaceholderResolver</title>
      <link>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-SystemPropertyPlaceholderResolver/</link>
      <pubDate>Wed, 06 Mar 2024 12:35:00 +0000</pubDate>
      <guid>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-SystemPropertyPlaceholderResolver/</guid>
      <description>Spring SystemPropertyPlaceholderResolver 类全路径: org.springframework.util.SystemPropertyUtils.SystemPropertyPlaceholderResolver 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 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(&amp;#34;Could not resolve placeholder &amp;#39;&amp;#34; + placeholderName + &amp;#34;&amp;#39; in [&amp;#34; + this.text + &amp;#34;] as system property: &amp;#34; + ex); return null; } } }</description>
    </item>
    <item>
      <title>Spring-ServletContextPlaceholderResolver</title>
      <link>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-ServletContextPlaceholderResolver/</link>
      <pubDate>Wed, 06 Mar 2024 12:34:00 +0000</pubDate>
      <guid>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-ServletContextPlaceholderResolver/</guid>
      <description>Spring ServletContextPlaceholderResolver 类全路径: org.springframework.web.util.ServletContextPropertyUtils.ServletContextPlaceholderResolver 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 private static class ServletContextPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver { private final String text; private final ServletContext servletContext; public ServletContextPlaceholderResolver(String text, ServletContext servletContext) { this.text = text; this.servletContext = servletContext; } @Override @Nullable public String resolvePlaceholder(String placeholderName) { try { // servlet 上下文获取 String propVal = this.servletContext.getInitParameter(placeholderName); if (propVal == null) { // Fall back to system properties. 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(&amp;#34;Could not resolve placeholder &amp;#39;&amp;#34; + placeholderName + &amp;#34;&amp;#39; in</description>
    </item>
    <item>
      <title>Spring-PropertyPlaceholderConfigurerResolver</title>
      <link>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-PropertyPlaceholderConfigurerResolver/</link>
      <pubDate>Wed, 06 Mar 2024 12:33:00 +0000</pubDate>
      <guid>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-PropertyPlaceholderConfigurerResolver/</guid>
      <description>Spring PropertyPlaceholderConfigurerResolver 类全路径: org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.PropertyPlaceholderConfigurerResolver 这个类是从 Properties 中获取属性 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 private final class PropertyPlaceholderConfigurerResolver implements PlaceholderResolver { private final Properties props; private PropertyPlaceholderConfigurerResolver(Properties props) { this.props = props; } @Override @Nullable public String resolvePlaceholder(String placeholderName) { return PropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, this.props, systemPropertiesMode); } } 详细方法如下 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 @Nullable protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) { String propVal = null; if (systemPropertiesMode == SYSTEM_PROPERTIES_MODE_OVERRIDE) { propVal = resolveSystemProperty(placeholder); } if (propVal == null) { propVal = resolvePlaceholder(placeholder, props); } if (propVal == null &amp;amp;&amp;amp; systemPropertiesMode == SYSTEM_PROPERTIES_MODE_FALLBACK) { propVal = resolveSystemProperty(placeholder); } return propVal; } 1 2 3 4</description>
    </item>
    <item>
      <title>Spring-PlaceholderResolver</title>
      <link>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-PlaceholderResolver/</link>
      <pubDate>Wed, 06 Mar 2024 12:32:00 +0000</pubDate>
      <guid>https://index.zshipu.com/geek/post/code/docs/Spring/clazz/PlaceholderResolver/Spring-PlaceholderResolver/</guid>
      <description>Spring PlaceholderResolver 类全路径: org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver 类作用将占位符中的内容替换成属性值. 假设现有属性表: user.dir = c:\home 传入参数 user.dir 会获得 c:\home 1 2 3 4 5 6 7 8 9 10 11 12 @FunctionalInterface public interface PlaceholderResolver { /** * Resolve the supplied placeholder name to the replacement value. * @param placeholderName the name of the placeholder to resolve * @return the replacement value, or {@code null} if no replacement is to be made */ @Nullable String resolvePlaceholder(String placeholderName); } 类图如下</description>
    </item>
  </channel>
</rss>
