java spring - override property value received from property file -
i have scenario, encoded password value property file. have own implementation of decryption, want decrypt password java class , want use decrypted value further, referred.
for example <bean id="mydatasource" class="org.apache.common.dbcp.basicdatasource" ... // more attributed set properties user, hostname etc. p:password="${mypropertey.password}" >
above code need implement below, specific password attribute, rest properties fine, password need decrypt before used.
(below implementation wrong, have mentioned give more , clear idea)
<bean id="mydatasource" class="org.apache.common.dbcp.basicdatasource" ... // more properties p:password="mydecryptbean.decryptmypassword(${mypropertey.password})" >
basically, need decrypt password, property file, before used establish database connection.
thanks time , !!
since using spring highly recommend looking propertyresourceconfigurer
class. see official documentation.
in particular take @ convertproperty(string propertyname, string propertyvalue)
method , consider creating class overrides it. able add in custom decryption logic overriden method, run every time spring accesses property.
directly documentation:
allows configuration of individual bean property values property resource, i.e. properties file. useful custom config files ... override bean properties configured in application context.
Comments
Post a Comment