草庐IT

具有@Value : dollar vs. 哈希的 Spring 表达式语言 (SpEL)($ 与 #)

与#{...}相比,何时使用${...}我有点困惑。Spring的文档只使用了#{...},但是有很多使用${...}的例子。此外,当我开始使用SpEL时,我被告知使用${...}并且效果很好。对于那些感到困惑的人,我如何使用它的一个例子是@ComponentpublicclassProxyConfiguration{@Value("${proxy.host}")privateStringhost;@Value("${proxy.port}")privateStringport;:}还有一些属性文件:proxy.host=myproxy.hostproxy.port=8000我的问题是