0

I have this myProperties.properties files with the following content:

enum1 = a
enum2 = b
enum3 = c
enum4 = d
and so on...

My problem is how can I populate or inject all property values in a Map<String,String> - enum1..4 as the key and 1..d as the value from Environment variable.

Thanks for your help.

James
  • 211
  • 3
  • 4
  • 12

1 Answers1

0

If you talking about java.util.Properties than there is no any problem in converting it to Map because it extends from Hashtable this means that you can simply convert it to Map:

Map<String, String> result = (Map)properties;
  • I am using the @ResourceProperty to read .property files. and then I access the property file via env.getProperty("key"). Is there a way to read the entire property file from the environment and inject it to a map? – James Aug 09 '17 at 00:44
  • The only thing I can suggest you in this case is to load properties manually, something like that: `prop.load(getClass().getClassLoader().getResourceAsStream("myproperties.properties"))` – Vitalii Muzalevskyi Aug 09 '17 at 09:01