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

Default ConfigSources

By default, a MicroProfile Config implementation must provide three sources of configuration:

  • System properties from the Java virtual machine (with an ordinal of 400)
  • Environment variables (with an ordinal of 300)
  • Properties stored in META-INF/microprofile-config.properties (with an ordinal of 100)
The ordinal value of a config source determines the precedence of the config source. In particular, if a property is defined both in the system properties and the environment variables, the value will be taken from the system properties (which has a higher ordinal than the environment variables).

There are no restrictions on the names of properties. However, some operating systems can impose some restrictions on the name of the environment variables (for example, "." is not allowed by most Unix shells). If you have a property that could be configured from the environment variables, you have to name your property accordingly.

For example, the property name my_url can be used by an environment variable while my.url cannot.

New in MicroProfile Config 1.3
MicroProfile Config 1.3 introduces a mapping rule from the config property name to the environment variable. This rule searches three environment variable variants for each property name:
  • Exact match
  • Replace any non-alphanumeric character with _
  • Replace any non-alphanumeric character with _ and use uppercase
This means that, in the Java application, we can have a property named  app.auth.url  and use the  APP_AUTH_URL  environment variable to configure it.

Let's move on to the other type of configuration source.

主站蜘蛛池模板: 横峰县| 海丰县| 丰镇市| 金堂县| 山丹县| 崇义县| 大同县| 白银市| 两当县| 溧水县| 固原市| 平遥县| 延寿县| 那坡县| 桐城市| 台安县| 哈巴河县| 容城县| 汨罗市| 盘山县| 阳城县| 宝应县| 余干县| 富源县| 阿瓦提县| 丰镇市| 拜城县| 巴中市| 甘南县| 安宁市| 当涂县| 普定县| 咸宁市| 临武县| 景谷| 八宿县| 金坛市| 阿鲁科尔沁旗| 平凉市| 土默特左旗| 正安县|