码迷,mamicode.com
首页 > 编程语言 > 详细

spring占位符解析器---PropertyPlaceholderHelper

时间:2016-06-11 15:43:37      阅读:984      评论:0      收藏:0      [点我收藏+]

标签:

一、PropertyPlaceholderHelper 职责

 

  扮演者占位符解析器的角色,专门用来负责解析路劲中or名字中的占位符的字符,并替换上具体的值

 

二、例子

public class PropertyPlaceholderHelperDemo {

    @SuppressWarnings("resource")
    public static void main(String[] args) {
        Properties properties = System.getProperties();
        
        properties.setProperty("prefixName", "read-code");
        
        ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:${prefixName}-spring.xml");
        
        ReadCodeService readCodeService = (ReadCodeService) ac.getBean("readCodeService");
        
        readCodeService.say();
    }
}

你可以debug进去,看下源码。底层PropertyPlaceholderHelper会去解析替换占位符value。

spring占位符解析器---PropertyPlaceholderHelper

标签:

原文地址:http://www.cnblogs.com/chenmo-xpw/p/5575359.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!