frm
frm

Reputation: 687

Optional arguments on Spring XML configuration with properties file

I have a project that reads .properties file from several clients, each of them has it's own config.

And I want to add a new optional property, so my project can work even if the property is not defined on the .properties file of the client.

My XML looks like this:

 <bean id="adapter"
      class="adapter.Source$SourceComponentFactory"
      p:url="$df{adapter.url}" p:authenticatedUrl="$df{adapter.authenticatedUrl}"
      p:jmsEnabled="$df{adapter.jmsEnabled}" p:jmsNamingUrl="$df{adapter.jmsNamingUrl}"

How can I make the last jmsNamingUrl optional, because if it isn't specify in the .properties file it raises an error, I remember something like :null or something like that.

Any ideas?

Thank you and best regards

Upvotes: 2

Views: 1699

Answers (1)

ikumen
ikumen

Reputation: 11663

I've never tried this specifically with p: namespace, but normally you could do something like this

<property name="jmsNamingUrl" value="$df{adapter.jmsNamingUrl:#{null}}" />

Upvotes: 2

Related Questions