Search code examples
springspring-bootdatasourceexternalspring-properties

SpringBoot complementary configuration file in system directory


I need some help to consume another .yml file that complement the original one in the application. Then I have a file filled by me(dev) however some configuration(as database infos) should be inserted by our clients.

The one which is in the application(application.yml) have general configs, the other on path C:\Users\Public\ datasource.yml have:

spring:
  datasource:
    platform: postgres
    driverClassName: org.postgresql.Driver
    url: jdbc:postgresql://localhost:5432/mydb
    username: foo
    password: bar

Has anyone done this before?


Solution

  • configure the below annotation at your main configuration class

    @PropertySource("classpath:datasource.yml")