Spring

 Reading an PCF Env variable of type Array into SpringBoot .properties file

Pankaj Bhalla's profile image
Pankaj Bhalla posted Jun 21, 2021 09:17 AM

Hi There.

 

As part of an application running on PCF, I have a user provided service that holds the hashes as an array. Let's say the user provided service is hash-config and we have a key "hashes" where the value is ["Hash1", "Hash2", "Hash3"]. How, I need to read this and have to populate a .properties field in SpringBoot application.

com.learn.pcf.hashes[]=${vcap.services.hash-config.credentials.hashes}

 

Problem statement: In place of an array, if I set env variable as "hashes":"Hash1", I mean a single value, then this value is successfully read as part of com.learn.pcf.hashes[], but whenever I add multiple values in the PCF env variable, system don't pick it as an array.

 

Can someone please suggest, what's the correct way to read an array type of env variables from PCF into the java code?

 

Many Thanks

PanB