If you run the following code with null:
@Value("#{systemProperties.someResourceLocation}")
private String someResourceLocation;
you will get the following exception:
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 17): Property or field 'someResourceLocation' cannot be found on object of type 'java.util.Properties' - maybe not public?
You can use the following code instead:
@Value("${someResourceLocation:" + DEFAULT_SOME_RESOURCE_LOCATION + "}")
private String someResourceLocation;
Reference:
http://javavirtuoso.blogspot.kr/2012/11/autowiring-optional-properties-with.html
No comments:
Post a Comment