3.2.3. 从 ConfigSource 类获取 ConfigSource


您可以创建和配置自定义 org.eclipse.microprofile.config.spi.ConfigSource 实施类,以提供配置值的来源。

流程

  • 以下管理 CLI 命令为名为 org.example.MyConfig Source 的实施类创建一个 Config Source,该类由名为 org.example 的 JBoss 模块提供。

    如果要使用 org.example 模块中的 ConfigSource,请将 <module name="org.eclipse.microprofile.config.api"/> 依赖项添加到 path/to/org/example/main/module.xml 文件。

    /subsystem=microprofile-config-smallrye/config-source=my-config-source:add(class={name=org.example.MyConfigSource, module=org.example})
    Copy to Clipboard Toggle word wrap

    此命令将为 microprofile-config-smallrye 子系统生成以下 XML 配置:

    <subsystem xmlns="urn:wildfly:microprofile-config-smallrye:1.0">
        <config-source name="my-config-source">
            <class name="org.example.MyConfigSource" module="org.example"/>
        </config-source>
    </subsystem>
    Copy to Clipboard Toggle word wrap

由自定义 org.eclipse.microprofile.config.spi.ConfigSource 实施类提供的属性可用于任何 JBoss EAP 部署。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部