Need Emergent Help ! How can I inject nested hashicorp object into Spring

Viewed 14

looking for emergent help !

I am trying to inject loaded yaml file content which stored in some Hashicrop Vault, we are loading the file like this on startup:

@PropertySources({
        @PropertySource(value = "file:/someVault/someSecretPath/someFile.yaml"), // some file contains the secrets
})
public class SomeConfigRunOnStartUp {
   ....
}

The roughly yaml file structure looks like this

{
  "someKey": [
    {
      "item1": "s1"
    },
    {
      "item2": "s2"
    },
    ....
  ],
}

I have tried to inject it in the spring with @Value annotation like below, but it doesn't work:

public class SomeFileReadRepo implements ParentRepo{

    @Value("${someKey}")
    private String[] credentials;

    public void readCreds(){
       System.out.println(credentials[0]);   
    //got  java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    }

I tried to print it out directly but got some random string of hash value...

 credentials = 

[Ljava.lang.String;@32238171

Any help will be much appreciated !!!!

0 Answers
Related