這是一個Spring項目,第一個PropertyPlaceholderConfigurer,在context-aaa.xml主要是配置JDBCpropertiesclasspath:jdbc.properties其中,jdbc.properties的內(nèi)容如下:test.datasource.url=jdbc:mysql://192.168.0.66:3306/devtest.datasource.username=roottest.datasource.password=123456第二個PropertyPlaceholderConfigurer,在context-bbb.xml,功能是從數(shù)據(jù)里加載properties問題來了,加載DruidDataSource時,占位符并沒有被替換。我已經(jīng)加了PropertyPlaceholderConfigurer的order屬性排序,以及ignoreUnresolvablePlaceholders為true了,但是問題依舊。DruidDataSource作為第二個PropertyPlaceholderConfigurer的依賴,它的配置占位符不會被處理嗎?我斷點發(fā)現(xiàn),BeanFactoryPostProcessor的處理,在程序的報錯之后才執(zhí)行,是怎么回事?https://jira.spring.io/browse...我找到了解決方案:Thealternativeisto(a)usethenewPropertySourcesPlaceholderConfigurerinsteadofthetraditionalPropertyPlaceholderConfigurer;(b)eliminatethefirstPropertySourcesPlaceholderConfigurer;(c)registeraPropertySourcewiththeApplicationContext'sEnvironmentthatcontainsthepropertiesfortheplaceholdersthatneedreplacementinthePropertySourcesPlaceholderConfigurer我想問第三步怎么操作???
[Spring] 多個 PropertyPlaceholderConfigurer 導(dǎo)致占位符未替換問題
瀟瀟雨雨
2019-05-21 11:11:15