哪个Spring Boot @ConfigurationProperties带注释的bean拥有spring.profiles.active属性?

问题描述 投票:1回答:1

我不想这样检索此属性:

@Value("${spring.profiles.active:local}")
private String profile;

[我想知道实际上是否有一个Spring Boot属性bean-即用@ConfigurationProperties注释-它保存spring.profiles.active(这是Spring属性,不是Spring Boot的)。

[例如SecurityProperties带有spring.security前缀。

谢谢。

java spring spring-boot configurationproperties
1个回答
2
投票

您可以使用Environment

Environment

然后:

@Autowired
Environment environment;
© www.soinside.com 2019 - 2024. All rights reserved.