简体   繁体   中英

Properties with same name are getting over written in spring vault 3.0.0

I have configs in HashiCorp vault with same names in different path.But when i try to access it, i am always end up with the config1 prop1 value is getting overridden by config2 prop1

Vault Path


path/stage/config1
    prop1
path/stage/config2
    prop1

Spring vault version :spring-cloud-starter-config-3.1.1 Spring boot starter version : 2.7.1

properties.yaml

spring:
  application:
    name: my-app
  cloud:
    kubernetes:
      enabled: false
  cloud.vault:
    uri: https://vaulturi
    connection-timeout: 5000
    read-timeout: 15000
    authentication: token
    token: ${keeper.token}
    namespace: name1/name2
    fail-fast: true
    kv:
      enabled: true
      backend: path/stage
      default-context: config1
  config:
    import: vault://path/stage/config1,vault://path/stage/config2
app:
 prop1:{$(prop1)}

Can i access prop1:{$(prop1)} like prop1:{$(config1.prop1)}

When i check the value in actuator/env, i get the following response

    {
        "name": "path/stage/config1",
        "properties": {
            "prop1": {
                "value": "test1"
            }
        }
    },
    {
        "name": "path/stage/config1",
        "properties": {
            "prop1": {
                "value": "test2"
            }
            
        }
    }

Can some one help me to fix this

Thanks Arun

Try to import vault://path/stage and then you have config1.prop1 and config2.prop1 You can then map them to specific properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM