Spring SpEL: how to write ternary operation in XML config?

Viewed 1179

In my Spring XML config, I need to set a value to a specific property value depending on the value of another property.

I need something like this:

<bean id="myid" class="myclass">
   <property name="myprop"
            value="#{${property_a} == 'test-a' ? ${property_b} : 'anothervalue'}"
   />

I want myprop to be set the value of property_b if property_a is equal to "test-a", otherwise myprop must be set to "anothervalue".

property_a and property_b are both defined in my config.properties file.

Is it possible to write such a statement in XML SpEL?

1 Answers
Related