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);
    }
}

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...