3.2.4. 从 ConfigSourceProvider 类获取 ConfigSource 配置


您可以创建和配置自定义 org.eclipse.microprofile.config.spi.ConfigSourceProvider 实施类,以注册多个 ConfigSource 实例的实施。

流程

  • 创建 config-source-provider

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

    命令为名为 org.example.MyConfigSourceProvider 的实现类创建一个 config-source-provider,它由名为 org.example 的 JBoss 模块提供。

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

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

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

ConfigSourceProvider 实施提供的属性可用于任何 JBoss EAP 部署。

其他资源

  • 有关如何将全局模块添加到 JBoss EAP 服务器的信息,请参阅 JBoss EAP 配置指南中的定义 全局模块
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部