I'm a little confused concerning when to use ${...}
compared to #{...}
. Spring's documentation only uses #{...}
, but there are plenty of examples that use ${...}
. Furthermore, when I started with SpEL I was told to use ${...}
and it works fine.
For those who are confused, an example of how I use it would be
@Component
public class ProxyConfiguration {
@Value("${proxy.host}")
private String host;
@Value("${proxy.port}")
private String port;
:
}
and some property file:
proxy.host=myproxy.host
proxy.port=8000
My questions are:
${...}
is the property placeholder syntax. It can only be used to dereference properties.
#{...}
is SpEL syntax, which is far more capable and complex. It can also handle property placeholders, and a lot more besides.
Both are valid, and neither is deprecated.