Showing posts with label PropertyPlaceholderConfigurer. Show all posts
Showing posts with label PropertyPlaceholderConfigurer. Show all posts

Saturday, May 9, 2009

Spring PropertyPlaceholderConfigurer

Here is the code to use PropertyPlaceholderConfigurer with XMLBeanFactory

XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("test.xml"));
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new ClassPathResource("jdbc.properties"));
// now actually do the replacement
cfg.postProcessBeanFactory(factory);
MyBean bean = (MyBean)factory.getBean("myBean");
System.out.println(bean .getProperty());