首页 > 解决方案 > spring 中的@Profile 注解可以使用占位符吗?

问题描述

spring 中的@Profile 注解可以使用占位符吗?

我想要 @Profile 注释,但里面的值是 ${spring.profile.active} ,它是使用占位符获得的。这有用吗?

@Configuration
@Profile("${spring.profile.active:local}")
public class Config {

}

我想知道 ${spring.profile.active} 是否可以正确获取值?

谢谢!

标签: javaspringspring-boot

解决方案


Spring @Profile 不支持 SPEL 从属性中获取值。使用带有属性占位符值的 @Profile 注释中提出的相同问题


推荐阅读