Using encoded password for the datasource used in spring applicationContext.xml

后端 未结 5 1000
野性不改
野性不改 2021-01-31 18:53

I want to keep encoded password in my below mentioned springApplicationContext.xml

Is there any way to achieve this?

presently I have configured all properties

5条回答
  •  北海茫月
    2021-01-31 19:27

    Create customized PropertyPlaceHolderConfigurer extending Spring PropertyPlaceHolderConfigurer

    public class PropertyPlaceholderConfigurer extends
            org.springframework.beans.factory.config.PropertyPlaceholderConfigurer {
    
        @Override
        protected String convertPropertyValue(final String originalValue) {
            if (originalValue.startwith("SomeText:")) {
                //Apply the decryption logic
                ...
            }
        }
    }
    

    You can encrypt the properties and append SomeText:. Use this customized PropertyPlaceHolderConfigurer to load the properties

提交回复
热议问题