Reputation: 127
I try to configure my spring app. And I need to define property placeholder like this:
<context:property-placeholder
location="classpath:ov.properties,file:#{appServerUrl.replaceFirst('regexp','')}/test.properties"
ignore-resource-not-found="true" />
But in result I have org.springframework.expression.ParseException: Expression 'file:#{appServerUrl.replaceFirst(''' @ 5: No ending suffix '}' for expression starting at character 5
If I invoke java method with one parameter only or without parameters, it works correctly. What's wrong? Thank you for reply.
Upvotes: 2
Views: 1289
Reputation: 7911
The parser for the <context:property-placeholder/>
elements first splits the value of the location
attribute using StringUtils.commaDelimitedListToStringArray(String)
. That is why is splits your second location in two.
To circumvent that, you could define a String
bean with the value of your second location:
<bean name="testPropertiesLocation" class="java.lang.String">
<constructor-arg value="file:#{appServerUrl.replaceFirst('regexp','')}/test.properties" />
</bean>
Then use it like this:
<context:property-placeholder
location="classpath:ov.properties,#{testPropertiesLocation}"
ignore-resource-not-found="true" />
Upvotes: 1