这是一个Spring项目,第一个PropertyPlaceholderConfigurer,在context-aaa.xml主要是配置JDBCpropertiesclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> classpath:jdbc.properties 其中,jdbc.properties的内容如下:test.datasource.url=jdbc:mysql://192.168.0.66:3306/devtest.datasource.username=roottest.datasource.password=123456第二个PropertyPlaceholderConfigurer,在context-bbb.xml,功能是从数据里加载propertiesclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> class="org.springmodules.commons.configuration.CommonsConfigurationFactoryBean"> 问题来了,加载DruidDataSource时,占位符并没有被替换。我已经加了PropertyPlaceholderConfigurer的order属性排序,以及ignoreUnresolvablePlaceholders为true了,但是问题依旧。DruidDataSource作为第二个PropertyPlaceholderConfigurer的依赖,它的配置占位符不会被处理吗?我断点发现,BeanFactoryPostProcessor的处理,在程序的报错之后才执行,是怎么回事?https://jira.spring.io/browse...我找到了解决方案:Thealternativeisto(a)usethenewPropertySourcesPlaceholderConfigurerinsteadofthetraditionalPropertyPlaceholderConfigurer;(b)eliminatethefirstPropertySourcesPlaceholderConfigurer;(c)registeraPropertySourcewiththeApplicationContext'sEnvironmentthatcontainsthepropertiesfortheplaceholdersthatneedreplacementinthePropertySourcesPlaceholderConfigurer我想问第三步怎么操作啊?
相关分类