I have a properties file defined in my xml:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/db.properties"></property>
</bean>
I have a property in the file:
someprop = one
Question
In my XML I would like to either add/remove a property in a bean definition. For example:
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.internal.url}" />
<!--I want to add/remove the line below based on value in property file-->
<property name="username" value="${jdbc.internal.username}" />
</bean>
This might be possible using SpringEL. Read the Expression support for defining bean definitions section here.
If this is to handle multiple environments then Spring 3.1 provides bean definition profiles and Environment abstractions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With