I\'m using spring 3 with PropertyPlaceholderConfigurator.
My properties code looks like as following:
@Configuration
public class MyProps {
@Val
You could use a default value:
@Value("${prop1:}")
public String prop1;
and spring will inject an empty string if the property isn't defined. The syntax is ${property:defaultValue}.
I'm not sure if it is possible to make a single property optional but surely you can force the property placeholder to ignore unresolved properties:
<context:property-placeholder ignore-unresolvable="true" ... />