java – 我可以在DropWizard中有多个配置文件吗?

前端之家收集整理的这篇文章主要介绍了java – 我可以在DropWizard中有多个配置文件吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想为DropWizard安装几个yaml文件.其中一个包含敏感信息和一个非敏感信息.

你可以指出我在DropWizard中有多个配置的任何文档或示例?

解决方法

ConfigurationSourceProvider是你的答案.
bootstrap.setConfigurationSourceProvider(new MyMultipleConfigurationSourceProvider());

以下是如何dropwizard does it by default.您可以轻松地将其更改为您自己的喜好.

public class FileConfigurationSourceProvider implements ConfigurationSourceProvider {
    @Override
    public InputStream open(String path) throws IOException {
        final File file = new File(path);
        if (!file.exists()) {
            throw new FileNotFoundException("File " + file + " not found");
        }

        return new FileInputStream(file);
    }
}
原文链接:https://www.f2er.com/java/123733.html

猜你在找的Java相关文章