1

I have a spring boot jar and I have properties defined in app-test.yml kept at src/main/resources within the jar. If i have the db details also in this single file, everything works fine.

But If I move the few properties in external file and run as :

java -jar -Dspring.profiles.active=test boot.jar --spring.config.location=location to external file/app-external.yml

it loads the profile test(as per log) hence should pick property from app-test.yml but fails for property present inside it:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'test.abc' in value "${test.abc}"

test.abc is defined in app-test.yml

Techno
  • 91
  • 1
  • 1
  • 6
  • try this: `java -jar -Dspring.profiles.active=test boot.jar --spring.config.additional-location=location to external file/app-external.yml` – Qiu Zhou Aug 31 '20 at 10:44
  • It doesnt work, gives error: Caused by: org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: --spring.config.additional-location – Techno Aug 31 '20 at 10:55
  • That won't work as you are now forcing Spring Boot to load a single file. Instead use `spring.boot.additional-config` instead of `spring.config.location`. – M. Deinum Aug 31 '20 at 12:29
  • I used this command: java -jar -Dspring.profiles.active=test boot.jar --spring.boot.additional-config=location/additional.properties it gives error: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. – Techno Sep 01 '20 at 06:59

0 Answers0