3

Its better to store the configuration properties in a database table so that it can be managed easily for different environments. The approach to store and retrieve the configuration properties from database table in xml based configuration is like below :

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> <property name="properties"> <bean class="org.apache.commons.configuration.ConfigurationConverter" factory-method="getProperties"> <constructor-arg> <bean class="org.apache.commons.configuration.DatabaseConfiguration"> <constructor-arg> <ref bean="dbDataSource" /> </constructor-arg> <constructor-arg value="DOMAIN_CONFIG" /> <!-- DB Table --> <constructor-arg value="CONFIG_NAME" /> <!-- DB Key Column --> <constructor-arg value="CONFIG_VALUE" /> <!-- DB Value Column --> </bean> </constructor-arg> </bean> </property> </bean> 

But the same thing i'm trying to achieve using java based configuration but no luck. Can anyone please help me.

1 Answer 1

4

I found answer for my question.

Thanks to this post : https://gist.github.com/jeffsheets/8ab5f3aeb74787bdb051 This exactly suits to my problem. Thanks.!

Sign up to request clarification or add additional context in comments.

1 Comment

Could ypu please post your solutıon as a gist as full source. I can not fınd CommonsConfigurationFactoryBean and DatabaseConfiguration classes ın the posted solutıon

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.