@Test public void customPlaceholderPrefixAndSuffix() { PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); ppc.setPlaceholderPrefix("@<"); ppc.setPlaceholderSuffix(">"); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", rootBeanDefinition(TestBean.class) .addPropertyValue("name", "@<key1>") .addPropertyValue("sex", "${key2}") .getBeanDefinition()); System.setProperty("key1", "systemKey1Value"); System.setProperty("key2", "systemKey2Value"); ppc.postProcessBeanFactory(bf); System.clearProperty("key1"); System.clearProperty("key2"); assertThat(bf.getBean(TestBean.class).getName(), is("systemKey1Value")); assertThat(bf.getBean(TestBean.class).getSex(), is("${key2}")); }
@Override public void setPlaceholderPrefix(String placeholderPrefix) { super.setPlaceholderPrefix(placeholderPrefix); this.configuredPlaceholderPrefix = placeholderPrefix; }
@Override public void setPlaceholderPrefix(String placeholderPrefix) { super.setPlaceholderPrefix(placeholderPrefix); this.placeholderPrefix = placeholderPrefix; }
public void setPlaceholderPrefix(String placeholderPrefix) { propertyPlaceholderConfigurer.setPlaceholderPrefix(placeholderPrefix); } public void setPlaceholderSuffix(String placeholderSuffix) {
props.setProperty("base.path", base); ppc.setProperties(props); ppc.setPlaceholderPrefix("#{"); log.info("base:"+base); ctx.addBeanFactoryPostProcessor(ppc);