0

When starting Spring context I have a bean that requires configuration files:

<bean id="ConfBean" class="com.FailSafeConfiguration">
    <property name="loeConf" value="${gi-alert-loeconf}"/>
    <property name="cdlConf" value="${gi-alert-cdlconf}"/>
    <property name="failSafeBean" ref="failSafeBean"/>
</bean>

If the files are missing the whole Java application doesn't start. Is there a way for this not to happen? Even if the properties don't have anything in them?

  • Added possible duplicate above that uses `@Value`, but the way the property is resolved is the same. – mkobit Jan 14 '15 at 22:50

1 Answers1

2

You can use SpEL to default these to null:

<property name="loeConf" value="${gi-alert-loeconf:#{null}}"/>

Essentially anything after the : will be used as a default, so put whatever type-specific value you want in there. ${gi-alert-loeconf:true} would work for boolean, ${gi-alert-loeconf:5} would work for int, etc.

Todd
  • 30,472
  • 11
  • 81
  • 89