0

im trying to access a property in a .conf file located in the target directory with my jar and its returning null. i followed the spring documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html#deployment-script-customization-conf-file

i believe i should be able to access the properties of the app.conf by simply coding the following:

System.out.println(System.getProperty("dbName"));
System.out.println(System.getProperty("dbUser"));
System.out.println(System.getProperty("dbPassword"));

all three return nulls when i try to run the jar from the terminal. my app.conf file looks like so:

JAVA_OPTS=-DdbName=RandomDb -DdbUser=devUser -DdbPassword=password90210

any recommendations to fix this? i know i can add them to the vm args in the run configs buts i would like to get this to work from a .conf file to avoid exposing sensitive information.

  • what OS are we talking about? – Rcordoval Jul 28 '18 at 05:30
  • have you tried stringified them? i mean... i guess the space between characters could dificult the proper parsing?... are you sure your jar is named **app.jar**? – Victor Jul 28 '18 at 05:31
  • I think this link can help you... https://stackoverflow.com/questions/18396535/where-which-properties-file-does-system-getpropertykey-reads-from – DhaRmvEEr siNgh Jul 28 '18 at 05:31

0 Answers0