• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set default argument value when using Spring constructor injection

Jonilie Echavez
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is it possible to set a default value for constructor arguments when using Spring constructor injection?

Here is my xml file where i define the argument values for the class SupplierImpl. It looks up the values from a properties file.

<bean id="supplier" class="com.healthopts.dao.supply.SupplierImpl">
<constructor-arg index="0"><value>${supplier.sourceLocator}</value></constructor-arg>
<constructor-arg index="1"><value>${supplier.reloadInterval}</value></constructor-arg>

Here is the properties file that is used to look up for the values to be passed in healthopts.spring.xml


Somewhere i have also already defined PropertyPlaceholderConfigurer that "healthopts.properties" is the name of the properties file to get the values from.

However, suppose the key called "supplier.reloadInterval" is not found in the properties file, is there a way to configure from my healthopts.spring.xml a default value for this argument?

Appreciate your help.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic