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.
For the most recent
information about using the Liberty
MicroProfile Config, see the Open Liberty website
and the Open Liberty
MicroProfile Config guides.
Procedure
-
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
-
Configure the feature. Update the server.xml file to add the
feature.
For example, configure the
server.xml
file to use the
mpConfig-1.3
feature. To enable the
mpConfig-1.3
feature, add the following feature definition to your
server.xml
file:
<featureManager>
<feature>mpConfig-1.3</feature>
</featureManager>
For
more information about
mpConfig-1.3
, see the MicroProfile Config 1.3 specification
at
https://github.com/eclipse/microprofile-config/releases/tag/1.3.
Optional: Both mpConfig-1.2
and
mpConfig-1.1
are still supported as configuration options.
-
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.
-
Use the API to access the configuration values.