External properties Spring boot

196 Views Asked by At

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).

1

There are 1 best solutions below

0
On

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.