Spring PropertyPlaceholderConfigurer从DB加载

是否可以使用Custom Spring PropertyPlaceholderConfigurer从DB加载属性? 提供给自定义PropertyPlaceholderConfigurer的数据源是否也可能在类路径中使用特定的属性文件?

我从以下链接找不到满意的答案?

http://www.mkyong.com/spring/spring-propertyplaceholderconfigurer-example/ http://www.codeproject.com/Articles/28893/Loading-Application-Properties-from-a-Database PropertyPlaceholderConfigurer查找数据库值和使用属性文件作为后备

Spring Context XML

        classpath:db.properties     ${imosdb.driver} ${imosdb.url} ${imosdb.username} ${imosdb.password} ${imosdb.initial_pool_size} ${imosdb.max_pool_size} ${imosdb.min_pool_size}                  classpath:static.properties file:static.properties         

Java PlaceholderClass

 import java.util.Properties; import javax.sql.DataSource; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; public class DbPropertySourcesPlaceholderConfigurer extends PropertyPlaceholderConfigurer { private static final String DEFAULT_DATASOURCENAME = "dataSource"; private static final String DEFAULT_DBTABLENAME = "property"; private static final String DEFAULT_DBKEYCOLUMNNAME = "key"; private static final String DEFAULT_DBVALUECOLUMNNAME = "value"; String dataSourceName; String dbTableName; String dbKeyColumnName; String dbValueColumnName; @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { DataSource dataSource = (DataSource) beanFactory.getBean(getDataSourceName()); // DbProperties dbProps = new DbProperties(dataSource); final Properties dbProps = new Properties(); dbProps.put("app.version", "v3"); setProperties(dbProps); super.postProcessBeanFactory(beanFactory); } public String getDataSourceName() { return dataSourceName==null?DEFAULT_DATASOURCENAME:dataSourceName; } public void setDataSourceName(String dataSourceName) { this.dataSourceName = dataSourceName; } } 

特别感谢以下页面的作者。

http://springtips.blogspot.com.tr/

http://ykchee.blogspot.com.tr/2012/09/spring-31-loading-properties-for-xml.html

http://blog.javaforge.net/post/31720600427/configuring-spring-based-web-application-from-database

http://www.javacodegeeks.com/2012/11/spring-3-1-loading-properties-for-xml-configuration-from-database.html