Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人可以在注释中的 SpEL 表达式中使用 bean 引用吗?(在 XML 中,绝对可以使用 #{} 中的 bean id)。一般来说,XML 文件中使用的 SpEL 表达式与 @Value 等注释中使用的表达式是否有任何限制/限制?
这是一个奇怪的问题——你为什么不尝试一下,如果某些东西没有按你的预期工作,你可以问一个具体的问题吗?
@Value但是,是的,您可以在...中使用 SpEL
@Value
@Value("#{@foo.substring(1) + @bar.substring(2)}") String foo;