- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中io.dropwizard.configuration.YamlConfigurationFactory
类的一些代码示例,展示了YamlConfigurationFactory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfigurationFactory
类的具体详情如下:
包路径:io.dropwizard.configuration.YamlConfigurationFactory
类名称:YamlConfigurationFactory
[英]A factory class for loading YAML configuration files, binding them to configuration objects, and validating their constraints. Allows for overriding configuration parameters from system properties.
[中]一个工厂类,用于加载YAML配置文件,将其绑定到配置对象,并验证其约束。允许从系统属性重写配置参数。
代码示例来源:origin: dropwizard/dropwizard
@Override
public ConfigurationFactory<T> create(
Class<T> klass,
Validator validator,
ObjectMapper objectMapper,
String propertyPrefix) {
return new YamlConfigurationFactory<>(
klass,
validator,
configureObjectMapper(objectMapper.copy()),
propertyPrefix);
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testConfigurationNamespaces1() throws Exception {
final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertEquals("/tmp/trellisData/namespaces.json", config.getNamespaces(), "Incorrect namespace location!");
}
代码示例来源:origin: performancecopilot/parfait
@Before
public void setUp() throws Exception {
objectMapper.getSubtypeResolver().registerSubtypes(
ConsoleReporterFactory.class,
CsvReporterFactory.class,
Slf4jReporterFactory.class,
ParfaitReporterFactory.class);
this.config = factory.build(new File(getClass().getResource("metric-app.yml").toURI()));
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testGetJwksAuthenticator() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwksAuthenticator,
"JWT auth not enabled!");
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testGetCORSConfig() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertTrue(TrellisUtils.getCorsConfiguration(config).isPresent(), "CORS configuration is missing!");
config.getCors().setEnabled(false);
assertFalse(TrellisUtils.getCorsConfiguration(config).isPresent(), "CORS config persists after disabling it!");
}
代码示例来源:origin: dropwizard/dropwizard
} else if (customPropertyPrefix.isPresent()) {
bootstrap.setConfigurationFactoryFactory((klass, validator, objectMapper, propertyPrefix) ->
new YamlConfigurationFactory<>(klass, validator, objectMapper, customPropertyPrefix.get()));
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testConfigurationLocations() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertEquals("http://localhost:8080/", config.getBaseUrl(), "Incorrect baseUrl!");
assertEquals("http://hub.example.com/", config.getHubUrl(), "Incorrect hubUrl!");
}
代码示例来源:origin: soabase/soabase
@Override
public ConfigurationFactory<T> create(Class<T> klass, Validator validator, ObjectMapper objectMapper, String propertyPrefix)
{
return new YamlConfigurationFactory<>(configurationClass, validator, objectMapper, propertyPrefix);
}
};
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testGetWebacCache() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertTrue(TrellisUtils.getWebacCache(config).isPresent(), "WebAC configuration not present!");
config.getAuth().getWebac().setEnabled(false);
assertFalse(TrellisUtils.getWebacCache(config).isPresent(), "WebAC config persists after disabling it!");
}
代码示例来源:origin: yammer/breakerbox
public YamlInstanceDiscovery(Path path,
Validator validator,
ObjectMapper objectMapper) {
this.path = path;
this.configurationFactory = new YamlConfigurationFactory<>(
YamlInstanceConfiguration.class,
validator,
objectMapper,
"dw");
parseYamlInstanceConfiguration();
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testGetJwtAuthenticatorNoKeystore() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
final String nonexistent = resourceFilePath("config1.yml").replaceAll("config1.yml", "nonexistent.yml");
config.getAuth().getJwt().setJwks(null);
config.getAuth().getJwt().setKeyStore(nonexistent);
assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
"JWT auth not disabled!");
}
代码示例来源:origin: bazaarvoice/ostrich
private static DictionaryConfiguration loadConfigFile(String configFile)
throws IOException, ConfigurationException {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
ConfigurationFactory<DictionaryConfiguration> configFactory = new YamlConfigurationFactory<>(
DictionaryConfiguration.class, validator, Jackson.newObjectMapper(), "dictionary"
);
if (configFile != null) {
return configFactory.build(new File(configFile));
} else {
return configFactory.build();
}
}
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testConfigurationAssets1() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertEquals("org/trellisldp/rdfa/resource.mustache", config.getAssets().getTemplate(), "Bad assets/template");
assertEquals("http://example.com/image.icon", config.getAssets().getIcon(), "Bad assets/icon value!");
assertTrue(config.getAssets().getJs().contains("http://example.com/scripts1.js"), "Missing assets/js value!");
assertTrue(config.getAssets().getCss().contains("http://example.com/styles1.css"), "Missing assets/css value!");
}
代码示例来源:origin: bazaarvoice/ostrich
private static CalculatorConfiguration loadConfigFile(String configFile) throws IOException,
ConfigurationException {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
ConfigurationFactory<CalculatorConfiguration> configFactory = new YamlConfigurationFactory<>(
CalculatorConfiguration.class, validator, Jackson.newObjectMapper(), "calculator"
);
if (configFile != null) {
return configFactory.build(new File(configFile));
} else {
return configFactory.build();
}
}
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testConfigurationAssets1() throws Exception {
final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertEquals("org/trellisldp/rdfa/resource.mustache", config.getAssets().getTemplate(), "Incorrect asset tpl!");
assertEquals("http://example.org/image.icon", config.getAssets().getIcon(), "Incorrect asset icon!");
assertTrue(config.getAssets().getJs().contains("http://example.org/scripts1.js"), "Incorrect asset js!");
assertTrue(config.getAssets().getCss().contains("http://example.org/styles1.css"), "Incorrect asset css!");
}
代码示例来源:origin: io.dropwizard/dropwizard-configuration
@Override
public ConfigurationFactory<T> create(
Class<T> klass,
Validator validator,
ObjectMapper objectMapper,
String propertyPrefix) {
return new YamlConfigurationFactory<>(
klass,
validator,
configureObjectMapper(objectMapper.copy()),
propertyPrefix);
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testGetJwtAuthenticatorBadKeystore() throws Exception {
final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
config.getAuth().getJwt().setJwks(null);
config.getAuth().getJwt().setKeyStore(resourceFilePath("config1.yml"));
assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
"JWT auth not disabled!");
}
代码示例来源:origin: bazaarvoice/ostrich
private static CalculatorConfiguration loadConfigFile(String configFile)
throws IOException, ConfigurationException {
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
ConfigurationFactory<CalculatorConfiguration> configFactory = new YamlConfigurationFactory<>(
CalculatorConfiguration.class, validator, Jackson.newObjectMapper(), "calculator"
);
if (configFile != null) {
return configFactory.build(new File(configFile));
} else {
return configFactory.build();
}
}
}
代码示例来源:origin: trellis-ldp/trellis
@Test
public void testConfigurationLocations() throws Exception {
final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
.build(new File(getClass().getResource("/config1.yml").toURI()));
assertEquals("/tmp/trellisData/binaries", config.getBinaries(), "Incorrect binary location!");
assertEquals("/tmp/trellisData/mementos", config.getMementos(), "Incorrect memento location!");
assertEquals("http://localhost:8080/", config.getBaseUrl(), "Incorrect base URL!");
assertEquals("http://hub.example.com/", config.getHubUrl(), "Incorrect hub URL!");
final String resources = "http://triplestore.example.com/";
config.setResources(resources);
assertEquals(resources, config.getResources(), "Incorrect resource location!");
}
代码示例来源:origin: io.dropwizard/dropwizard-testing
} else if (customPropertyPrefix.isPresent()) {
bootstrap.setConfigurationFactoryFactory((klass, validator, objectMapper, propertyPrefix) ->
new YamlConfigurationFactory<>(klass, validator, objectMapper, customPropertyPrefix.get()));
本文整理了Java中io.dropwizard.configuration.YamlConfigurationFactory.()方法的一些代码示例,展示了YamlConfigurationFacto
本文整理了Java中io.dropwizard.configuration.YamlConfigurationFactory.build()方法的一些代码示例,展示了YamlConfiguration
我是一名优秀的程序员,十分优秀!