There are no conditional mechanisms for Spring bean XML defrag files. However, perhaps this will work:
<bean class="#{prop=='a' ? BeanA : BeanB}"/>
But even if this approach worked, it would not be the most readable one. My suggestion was to use a different set of XML configuration files and select them depending on some global settings. Naturally, you would put all the ordinary beans (i.e. those whose definition is always the same) in a separate file and always include it.
source share