Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 315
padmanabhanm Avatar asked Oct 17 '25 08:10

padmanabhanm


1 Answers

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.

like image 107
Manish Bansal Avatar answered Oct 18 '25 22:10

Manish Bansal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!