LATEST VERSION: 3.0 - RELEASE NOTES
Spring Cloud Services v3.0

Configuration Properties

Page last updated:

The Config Server can serve configuration properties from either Git or HashiCorp Vault configuration sources. Configuration properties can be applicable to all apps that use the Config Server, specific to an app, or specific to a Spring application profile.

See below for information about the structure and format of configuration properties to be served by the Config Server.

Git

If using a Git configuration source, you must store properties in YAML or Java .properties files.

Global Configuration

You can store configuration properties so that they are served to all apps which use the Config Server. In the configuration repository, a file named application.yml or application.properties contains configuration which will be served to all apps that access the Config Server.

Using YAML

An example of a global application.yml file:

message: Hi there!

Using a Properties File

An example of a global application.properties file:

message=Hi there!

Application-Specific Configuration

You can store configuration properties so that they are served only to a specific app. In the configuration repository, a file named [APP-NAME].yml or [APP-NAME].properties, where [APP-NAME] is the name of an app, contains configuration which will be served only to the APP-NAME app.

Using YAML

An example of an app-specific cook.yml file:

server:
  port: 80

cook:
  special: Fried Salamander

Using a Properties File

An example of an app-specific cook.properties file:

server.port=80

cook.special=Fried Salamander

Profile-Specific Configuration

You can store configuration properties so that they are served only to apps which have activated a specific Spring application profile. In the configuration repository, a file named [APP-NAME]-[PROFILE-NAME].yml or [APP-NAME]-[PROFILE-NAME].properties, where [APP-NAME] is the name of an app and [PROFILE-NAME] is the name of an application profile, contains configuration which will be served only to the APP-NAME app running with the [PROFILE-NAME] profile activated. Within a YAML file named [APP-NAME].yml, a document that begins by setting the spring.profiles property contains configuration which will be served only to the APP-NAME app running with the profile specified by the spring.profiles property.

Using YAML

An example of a profile-specific cook-dev.yml file:

server:
  port: 8080

cook:
  special: Birdfeather Tea

An example of a profile-specific YAML document within a cook.yml file:

---
spring:
  profiles: dev

server:
  port: 8080

cook:
  special: Birdfeather Tea

Using a Properties File

An example of a profile-specific cook-dev.properties file:

server.port=8080

cook.special=Birdfeather Tea

Plain Text Configuration

You can store configuration in files of other file types. The Spring Cloud Services Config Client library includes a PlainTextConfigClient that can be used to retrieve the contents of a plain text file as a Spring Resource.

For more information about using the Config Server to serve plain text files to a client app, see the Use Plain Text Configuration Files section of Writing Client Applications.

Vault

If using a HashiCorp Vault configuration source, you must write secrets to the Vault server using the vault Command Line Interface (CLI) tool.

Global Configuration

You can store configuration properties so that they are served to all apps which use the Config Server. A secret written to the secret/application path will be served to all apps that access the Config Server.

An example of setting a global configuration property:

$ vault write secret/application message=Greetings

Application-Specific Configuration

You can store configuration properties so that they are served only to a specific app. A secret written to the secret/[APP-NAME] path contains configuration which will be served only to the APP-NAME app.

An example of setting an app-specific configuration property:

$ vault write secret/cook message=Hi

Profile-Specific Configuration

You can store configuration properties so that they are served only to apps which have activated a specific Spring application profile. A secret written to the secret/[APP-NAME],[PROFILE-NAME] path, where [APP-NAME] is the name of an app and [PROFILE-NAME] is the name of an application profile, contains configuration which will be served only to the APP-NAME app running with the [PROFILE-NAME] profile activated.

An example of setting a profile-specific configuration property:

$ vault write secret/cook,dev message=Ho
Create a pull request or raise an issue on the source for this page in GitHub