[17.0.0.3 and later]

Enabling the MicroProfile Config API

To configure the Liberty server to run an application that is enabled for the MicroProfile Config API, you must set the feature for the server.

Procedure

  1. Using the MicroProfile Config API information, decide what configuration parameters are required by your code. Consider how these configuration values can be stored and how they might vary across services and over the lifetime of the service from:
    • Development
    • Test
    • Assembly and installation
    • Runtime service scaling and failover
  2. Configure the feature. Update the server.xml file to add the feature. For example:
    <featureManager>
        <feature>mpConfig-1.1</feature>
    </featureManager>

    Liberty can be configured to support the MicroProfile 1.1 features by setting microProfile-1.1 in the server.xml file. However, the MicroProfile Config API was produced after the MicroProfile 1.1 release and is not made available using that feature.

    [18.0.0.1 and later]You can configure the server.xml file to use the mpConfig-1.2 feature instead of the mpConfig-1.1 feature. To enable the mpConfig-1.2 feature, add the following feature definition to your server.xml file:
    <featureManager>
        <feature>mpConfig-1.2</feature>
    </featureManager>
    For more information about mpConfig-1.2, see the MicroProfile Config 1.2.1 specification at https://github.com/eclipse/microprofile-config/releases/tag/1.2.1.
  3. Create appropriate configuration value sources. For example, property files can be packaged with an application and the value sources can be overridden later. This can happen during application composition by using property files in an EAR assembly, Liberty shared libraries, or server process environment variables.
  4. Use the API to access the configuration values.

Icon that indicates the type of topic Task topic

File name: twlp_microprofile_appconfig_setup.html