Search code examples
springspring-bootspring-cloudspring-config

Custom file names in Spring Cloud Config Server


How to specify a spring boot application to access only a specific .properties file among other files in my Spring Cloud Config Server.

My Spring Cloud Config has the following files: application.properties,order-dev.properties,inventory-dev.properties, all my db and messaging properties are in order-dev and inventory-dev files.

Now I wish to move those properties to orderdb-dev, inventorydb-dev, ordermsg-dev and inventorymsg-dev files.

How do I configure my order and inventory service to pick the property from orderdb-dev, inventorydb-dev, ordermsg-dev and inventorymsg-dev files ? I have been going around to find the property for the same. Read through the official documentation and felt lost. Any help would be appreciated.


Solution

  • Add a bootstrap.yml file under resources folder. Then add the below properties.

    spring:
      application:
        name: order   
      cloud:
        config:
          name: ${spring.application.name}, orderdb, ordermsg
          profile: dev
    

    This way, it will first load the properties from order-dev.properties file. Then orderdb-dev.properties and then ordermsg-dev.properties.