Spring @Value escape colon(:) in default value Spring @Value escape colon(:) in default value spring spring

Spring @Value escape colon(:) in default value


Update:For spring 4.2 and higher, no single quotes are needed. Spring will see the first colon as special, and use all the rest as a single string value.

For spring 4.2 and higher,

@Value("${prop.url:http://myurl.com}")

For the previous versions, I believe single quotes will do the trick:

@Value("${prop.url:'http://myurl.com'}")


On Spring version 3.2 the default value works without quotes.


If you need to pass a list of Strings that contain colon with default value then do like:

@Value("${parameterName:}#{T(java.util.Arrays).asList(\"abc:1\",\"def:2\")}")private List<String> parameters;