【问题标题】:How to determine programmatically the current active profile using Spring boot [duplicate]如何使用 Spring Boot 以编程方式确定当前的活动配置文件 [重复]
【发布时间】:2015-04-08 03:46:26
【问题描述】:

有没有办法以编程方式在我的 bean 中获取当前活动的配置文件?

【问题讨论】:

    标签: java spring spring-boot


    【解决方案1】:

    不管你的应用是 Boot 还是原始 Spring。将org.springframework.core.env.Environment 注入到您的 bean 中就足够了。

    @Autowired
    private Environment environment;
    ....
    
    this.environment.getActiveProfiles();
    

    【讨论】:

    猜你喜欢
    • 2015-09-24
    • 2012-03-05
    相关资源
    最近更新 更多