我想要 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);
}
}
关于java - 我可以在 DropWizard 中拥有多个配置文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28727224/