Include common config for multiple apps in Spring Cloud Config server

Probably it's too late already, but in case someone else is struggling with the same issue, the final solution is as follows:

You can create as many yml files under config-server classpath as you wish. Even if it is in native profile selected, there will be provided to client applications. The only thing not mentioned before is, you should tell the client application to read those settings files as well.

Here is a working example:

Config server file structure:

resources
|-config
   |-auth-service.yml - service specific configuration file
|-application.yml - config server settings
|-settings.yml - general settings file, planed to be loaded in every service

Client application bootstrap.yml file:

spring:
application:
  name: auth-service
cloud:
  config:
    username: "config-user"
    password: "config-password-1234"
    uri: "http://config-service:8888"
    name: ${spring.application.name}, settings

The key is name: ${spring.application.name}, settings which tells the config client to load the following settings from the config server:

  • ${spring.application.name} which will load config/auth-service.yml
  • settings which will load settings.yml

Yes. You can have application.yml or application-<profile>.yml on your config server and now every application that is using this config server will inherit all settings in application.yml. Every application that runs in specific profile will inherit settings from application-<profile>.yml.