Skip to main content

microprofile-config

View Github Project

Welcome to MicroProfile Config

The majority of applications need to be configured based on a running environment. It must be possible to modify configuration data from outside an application so that the application itself does not need to be repackaged.

The configuration data can come from different locations and in different formats (e.g. system properties, system environment variables, .properties, .xml, datasource). We call these config locations ConfigSources. If the same property is defined in multiple ConfigSources, we apply a policy to specify which one of the values will effectively be used.

Under some circumstances, some data sources may change dynamically. The changed values should be fed into the client without the need for restarting the application. This requirement is particularly important for microservices running in a cloud environment. The MicroProfile Config approach allows to pick up configured values immediately after they got changed.

Released versions

Config 3.0:    Javadocs    |    Spec PDF    |    Spec html
Config 2.0:    Javadocs    |    Spec PDF    |    Spec html
Config 1.4:    Javadocs    |    Spec PDF     |    Spec html
Config 1.3:    Javadocs    |    Spec PDF     |    Spec html
Config 1.2:    Javadocs    |    Spec PDF     |    Spec html

Design

The current configuration of an application can be accessed via ConfigProvider#getConfig().

Config consists of the information collected from the registered org.eclipse.microprofile.config.spi.ConfigSource s. These ConfigSource s get sorted according to their ordinal. That way it is possible to overwrite configuration with lower importance from outside.

By default there are 3 default ConfigSources:

  • System.getProperties() (ordinal=400)
  • System.getenv() (ordinal=300)
  • all META-INF/microprofile-config.properties files on the ClassPath. (default ordinal=100, separately configurable via a config_ordinal property inside each file)

Therefore, the default values can be specified in the above files packaged with the application and the value can be overwritten later for each deployment. A higher ordinal number takes precedence over a lower number.

Custom ConfigSources

It is possible to write and register a custom ConfigSources. An example would be a ConfigSource which gets the configured values from a shared database table in a cluster.

Building

The whole MicroProfile config project can be built via Apache Maven

$> mvn clean install

Contributing

Do you want to contribute to this project? Find out how you can help here

Help optimize Enterprise Java for a microservices architecture.

Join the MicroProfile Google Group, peruse recent topics or create your own, and join in on the conversation. It's that easy!

JOIN THE DISCUSSION