You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于REST API请求动态激活Spring Boot对应Profile

根据请求体字段动态激活Spring Boot Profile

现有多Profile配置

我在Spring Boot项目中使用了如下多Profile专属配置段:

spring:
  config:
    activate:
      on-profile: tenant1
some-property: value1
spring:
  config:
    activate:
      on-profile: tenant2
some-property: value2

需求说明

现有一个POST请求,请求体中会携带some-property字段,示例请求体格式如下:

{
"some-property": "value2"
}

需要实现的逻辑是:根据请求体中some-property的值,匹配对应Profile配置里的some-property值,从而激活对应的Profile。比如上述示例中,请求体的some-property值为value2,与tenant2 Profile对应的配置值匹配,因此应激活tenant2 Profile。

内容的提问来源于stack exchange,提问作者user16138227

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 16:14:51