Reputation: 1517
I have below bean definition in my spring XML.
I want to include it conditionally if specific property is true
If includeCustomBean==true
<bean id="message"
class="com.CustomReloadableResourceBundleMessageSource">
</bean>
else
<bean id="message"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
</bean>
Is it possible ?
Upvotes: 1
Views: 4485
Reputation: 2655
you can use Spring expression language just like below example.
<bean class="com.example.MyBean">
<property name="dependency" value="#{systemProperties['foo'] == 'bar'
? dependencyX : dependencyY}" />
</bean>
or profile is another concept
https://dzone.com/articles/using-spring-profiles-xml
Upvotes: 4