官术网_书友最值得收藏!

Understanding Eclipse MicroProfile Config

Every application needs some external configuration to adapt its behavior to the runtime platform it's running on. It can range from the HTTP endpoints that the application must connect to, or the size of some internal structures.

These configuration parameters can also come from different sources:

  • From the operating system or the container in a cloud-native environment (through the use of environment variables)
  • From the Java virtual machine (with system properties)
  • From some external configuration files (such as the Java properties file)
  • From other places (an LDAP server, database, key-value store, and so on)

On the one hand, these configuration parameters come from many different sources. On the other hand, we want to consume them in the Java application in a simple way that does not depend on the source of the configuration. The Eclipse MicroProfile Config specification addresses this problem.

The MicroProfile Config API is split into two parts that tackle the two sides of the problem:

  • The API defines the Config and @ConfigProperty types that are used by the Java application to get the values of the configuration parameters.
  • The API also defines a Service Provider Interface (SPI) to let other projects (or the Java application itself) provide the sources of configuration parameters.

Implementations of MicroProfile Config must provide default ConfigSource implementations that are always available to the application.

For most use cases, the application will mainly be interested in reading configuration from the Config API, which we will cover in the next section.

主站蜘蛛池模板: 山东| 新泰市| 福贡县| 左贡县| 凌云县| 昌乐县| 习水县| 建湖县| 都江堰市| 云梦县| 北海市| 和林格尔县| 同德县| 遂宁市| 连山| 阜平县| 新干县| 信阳市| 思南县| 双辽市| 太湖县| 旅游| 交城县| 科技| 望都县| 周至县| 志丹县| 湄潭县| 苏州市| 富民县| 大渡口区| 马鞍山市| 漳浦县| 涿鹿县| 营口市| 仁化县| 高雄县| 内江市| 阿巴嘎旗| 皮山县| 东乌珠穆沁旗|