0

I'm trying to get my spring boot project to use properties defined outside of project. I have tried the steps described in docs but I'm unable to get it to work.

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

.
+- folder
   +- properties
      +- application.properties
   +- myproject
      +- src

I'm using this for VM options: -Dspring.config.location=file:../properties/ but it's not working. I tried multiple values for spring.config.location with no success (I suppose the issue is from here).

Vlad Dobrieski
  • 53
  • 1
  • 1
  • 4
  • #1. Try with the full qualified path on your VM options, example: `-Dspring.config.location=file:/app/config/properties/`. #2. Try with the `--` option instead of VM options, example: `java -jar myproject.jar --spring.config.location=file:../properties/` – Rafa Sep 16 '17 at 14:18

1 Answers1

0

Let's say I've an app which connects to Postgresql Database. I've my database connection details outside of my project which is in some centralized version control system. I'm using bootstrap.properties file in my app. I've configured in bootstrap.properties to fetch my database connection details at app startup. For Example,

postgresql.database.url:${databaseUrl}
postgresql.database.username:${databaseUsername}
postgresql.database.password:${databasePassword}

I'm passing config keys as values in bootstrap.properties. During app runtime, it will fetch the corresponding values based on keys.

Kumaresh Babu N S
  • 1,648
  • 5
  • 23
  • 39