当前位置: 首页>>代码示例>>Java>>正文


Java RelaxedDataBinder类代码示例

本文整理汇总了Java中org.springframework.boot.bind.RelaxedDataBinder的典型用法代码示例。如果您正苦于以下问题:Java RelaxedDataBinder类的具体用法?Java RelaxedDataBinder怎么用?Java RelaxedDataBinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RelaxedDataBinder类属于org.springframework.boot.bind包,在下文中一共展示了RelaxedDataBinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMatchOutcome

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConfigurableEnvironment environment = (ConfigurableEnvironment) context
			.getEnvironment();
	ResourceProperties properties = new ResourceProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
	binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
	Boolean match = properties.getChain().getEnabled();
	if (match == null) {
		boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
				getClass().getClassLoader());
		return new ConditionOutcome(webJarsLocatorPresent,
				"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
						+ (webJarsLocatorPresent ? "present" : "absent"));
	}
	return new ConditionOutcome(match,
			"Resource chain is " + (match ? "enabled" : "disabled"));
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:20,代码来源:OnEnabledResourceChainCondition.java

示例2: testBindingSsh

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testBindingSsh() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	Map<String, String> map = new HashMap<String, String>();
	map.put("shell.ssh.enabled", "true");
	map.put("shell.ssh.port", "2222");
	map.put("shell.ssh.key_path", "~/.ssh/test.pem");
	binder.bind(new MutablePropertyValues(map));
	assertFalse(binder.getBindingResult().hasErrors());

	Properties p = props.asCrshShellConfig();

	assertEquals("2222", p.get("crash.ssh.port"));
	assertEquals("~/.ssh/test.pem", p.get("crash.ssh.keypath"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ShellPropertiesTests.java

示例3: testBindingSshIgnored

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testBindingSshIgnored() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	Map<String, String> map = new HashMap<String, String>();
	map.put("shell.ssh.enabled", "false");
	map.put("shell.ssh.port", "2222");
	map.put("shell.ssh.key_path", "~/.ssh/test.pem");
	binder.bind(new MutablePropertyValues(map));
	assertFalse(binder.getBindingResult().hasErrors());

	Properties p = props.asCrshShellConfig();

	assertNull(p.get("crash.ssh.port"));
	assertNull(p.get("crash.ssh.keypath"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ShellPropertiesTests.java

示例4: testBindingSimple

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testBindingSimple() {
	SimpleAuthenticationProperties props = new SimpleAuthenticationProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.simple");
	binder.setConversionService(new DefaultConversionService());
	Map<String, String> map = new HashMap<String, String>();
	map.put("shell.auth.simple.user.name", "username123");
	map.put("shell.auth.simple.user.password", "password123");
	binder.bind(new MutablePropertyValues(map));
	assertFalse(binder.getBindingResult().hasErrors());

	Properties p = new Properties();
	props.applyToCrshShellConfig(p);

	assertEquals("username123", p.get("crash.auth.simple.username"));
	assertEquals("password123", p.get("crash.auth.simple.password"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ShellPropertiesTests.java

示例5: druidDataSource

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Bean(name = "commonDataSource")
@Primary
public DataSource druidDataSource() {
	DruidDataSource dataSource = new DruidDataSource();
	MutablePropertyValues properties = new MutablePropertyValues(beautyDruidDataProperties());
	new RelaxedDataBinder(dataSource).bind(properties);
	return dataSource;
}
 
开发者ID:zhaoqilong3031,项目名称:spring-cloud-samples,代码行数:9,代码来源:DataSourceConfig.java

示例6: bindXaProperties

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
private void bindXaProperties(XADataSource target, DataSourceProperties properties) {
	MutablePropertyValues values = new MutablePropertyValues();
	values.add("user", this.properties.determineUsername());
	values.add("password", this.properties.determinePassword());
	values.add("url", this.properties.determineUrl());
	values.addPropertyValues(properties.getXa().getProperties());
	new RelaxedDataBinder(target).withAlias("user", "username").bind(values);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:XADataSourceAutoConfiguration.java

示例7: getExcludeAutoConfigurationsProperty

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
private List<String> getExcludeAutoConfigurationsProperty() {
	if (getEnvironment() instanceof ConfigurableEnvironment) {
		Excludes excludes = new Excludes();
		RelaxedDataBinder binder = new RelaxedDataBinder(excludes,
				"spring.autoconfigure.");
		binder.bind(new PropertySourcesPropertyValues(
				((ConfigurableEnvironment) getEnvironment()).getPropertySources()));
		return excludes.getExclude();
	}
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(),
			"spring.autoconfigure.");
	String[] exclude = resolver.getProperty("exclude", String[].class);
	return (Arrays.asList(exclude == null ? new String[0] : exclude));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:EnableAutoConfigurationImportSelector.java

示例8: setEnvironment

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Override
public void setEnvironment(Environment environment) {
	this.environment = (ConfigurableEnvironment) environment;
	this.target = new HashMap<String, Object>();
	new RelaxedDataBinder(this.target).bind(
			new PropertySourcesPropertyValues(this.environment.getPropertySources()));
	this.propertyResolver = new RelaxedPropertyResolver(environment);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:MustacheEnvironmentCollector.java

示例9: testAddressBinding

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testAddressBinding() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.address", "127.0.0.1")));
	assertThat(binder.getBindingResult().hasErrors()).isFalse();
	assertThat(this.properties.getAddress())
			.isEqualTo(InetAddress.getByName("127.0.0.1"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java

示例10: testServerHeader

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testServerHeader() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.server-header", "Custom Server")));
	assertThat(this.properties.getServerHeader()).isEqualTo("Custom Server");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ServerPropertiesTests.java

示例11: testServletPathAsMapping

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testServletPathAsMapping() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.servletPath", "/foo/*")));
	assertThat(binder.getBindingResult().hasErrors()).isFalse();
	assertThat(this.properties.getServletMapping()).isEqualTo("/foo/*");
	assertThat(this.properties.getServletPrefix()).isEqualTo("/foo");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java

示例12: testServletPathAsPrefix

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testServletPathAsPrefix() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.servletPath", "/foo")));
	assertThat(binder.getBindingResult().hasErrors()).isFalse();
	assertThat(this.properties.getServletMapping()).isEqualTo("/foo/*");
	assertThat(this.properties.getServletPrefix()).isEqualTo("/foo");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java

示例13: bind

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
private void bind(DataSource result) {
	MutablePropertyValues properties = new MutablePropertyValues(this.properties);
	new RelaxedDataBinder(result)
			.withAlias("url", "jdbcUrl")
			.withAlias("username", "user")
			.bind(properties);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:8,代码来源:DataSourceBuilder.java

示例14: preInit

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Override
public void preInit(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
  GenericProperties genericProperties = camundaBpmProperties.getGenericProperties();
  final Map<String, Object> properties = genericProperties.getProperties();
  if (!CollectionUtils.isEmpty(properties)) {
    RelaxedDataBinder relaxedDataBinder = new RelaxedDataBinder(springProcessEngineConfiguration);
    relaxedDataBinder.setIgnoreInvalidFields(genericProperties.isIgnoreInvalidFields());
    relaxedDataBinder.setIgnoreUnknownFields(genericProperties.isIgnoreUnknownFields());
    relaxedDataBinder.bind(getPropertyValues(properties));
    logger.debug("properties bound to configuration: {}", genericProperties);
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:13,代码来源:GenericPropertiesConfiguration.java

示例15: testBindingAuth

import org.springframework.boot.bind.RelaxedDataBinder; //导入依赖的package包/类
@Test
public void testBindingAuth() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("shell.auth", "spring")));
	assertFalse(binder.getBindingResult().hasErrors());
	assertEquals("spring", props.getAuth());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:ShellPropertiesTests.java


注:本文中的org.springframework.boot.bind.RelaxedDataBinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。