基于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
相关产品推荐
相关产品推荐

