4

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.

padmanabhanm
  • 315
  • 3
  • 15

1 Answers1

14

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.

Manish Bansal
  • 2,400
  • 2
  • 21
  • 37
  • 2
    Thanks that worked. Where is the documentation mentioned for this ? I read the whole official doc and couldn't find this property. – padmanabhanm Jun 03 '19 at 07:35
  • 3
    Even i couldn't find the doc reference. There is a GitHub issue which mentions this solution and an ask for doc update. Not sure if it was done ever. https://github.com/spring-cloud/spring-cloud-config/issues/618 – Manish Bansal Jun 03 '19 at 08:31