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})/subsystem=microprofile-config-smallrye/config-source-provider=my-config-source-provider:add(class={name=org.example.MyConfigSourceProvider, module=org.example})Copy to Clipboard Copied! Toggle word wrap Toggle overflow 命令为名为
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><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 Copied! Toggle word wrap Toggle overflow
ConfigSourceProvider 实施提供的属性可用于任何 JBoss EAP 部署。
其他资源
- 有关如何将全局模块添加到 JBoss EAP 服务器的信息,请参阅 JBoss EAP 配置指南中的定义 全局模块。