• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ConfigurationPropertySources类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testCanUseClientCredentials

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
@Test
public void testCanUseClientCredentials() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(TestSecurityConfiguration.class,
			MinimalSecureWebApplication.class);
	TestPropertyValues
			.of("security.oauth2.client.clientId=client",
					"security.oauth2.client.grantType=client_credentials")
			.applyTo(this.context);
	ConfigurationPropertySources.attach(this.context.getEnvironment());
	this.context.refresh();
	OAuth2ClientContext bean = this.context.getBean(OAuth2ClientContext.class);
	assertThat(bean.getAccessTokenRequest()).isNotNull();
	assertThat(countBeans(ClientCredentialsResourceDetails.class)).isEqualTo(1);
	assertThat(countBeans(OAuth2ClientContext.class)).isEqualTo(1);
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:17,代码来源:OAuth2AutoConfigurationTests.java


示例2: testCanUseClientCredentialsWithEnableOAuth2Client

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
@Test
public void testCanUseClientCredentialsWithEnableOAuth2Client() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(ClientConfiguration.class,
			MinimalSecureWebApplication.class);
	TestPropertyValues
			.of("security.oauth2.client.clientId=client",
					"security.oauth2.client.grantType=client_credentials")
			.applyTo(this.context);
	ConfigurationPropertySources.attach(this.context.getEnvironment());
	this.context.refresh();
	// The primary context is fine (not session scoped):
	OAuth2ClientContext bean = this.context.getBean(OAuth2ClientContext.class);
	assertThat(bean.getAccessTokenRequest()).isNotNull();
	assertThat(countBeans(ClientCredentialsResourceDetails.class)).isEqualTo(1);
	// Kind of a bug (should ideally be 1), but the cause is in Spring OAuth2 (there
	// is no need for the extra session-scoped bean). What this test proves is that
	// even if the user screws up and does @EnableOAuth2Client for client credentials,
	// it will still just about work (because of the @Primary annotation on the
	// Boot-created instance of OAuth2ClientContext).
	assertThat(countBeans(OAuth2ClientContext.class)).isEqualTo(2);
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:23,代码来源:OAuth2AutoConfigurationTests.java


示例3: getMatchOutcome

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
    AnnotatedTypeMetadata metadata) {
  String prefix = (String) attribute(metadata, "prefix");
  Class<?> value = (Class<?>) attribute(metadata, "value");
  ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
  try {
    new Binder(ConfigurationPropertySources.from(environment.getPropertySources()))
        .bind(prefix, Bindable.of(value))
        .orElseThrow(
            () -> new FatalBeanException("Could not bind DataSourceSettings properties"));
    return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix));
  } catch (Exception e) {
    //ignore
  }
  return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix));
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:18,代码来源:PrefixPropertyCondition.java


示例4: testDisablingAuthorizationServer

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
@Test
public void testDisablingAuthorizationServer() {
	this.context = new AnnotationConfigServletWebServerApplicationContext();
	this.context.register(ResourceServerConfiguration.class,
			MinimalSecureWebApplication.class);
	TestPropertyValues.of("security.oauth2.resource.jwt.keyValue:DEADBEEF")
			.applyTo(this.context);
	ConfigurationPropertySources.attach(this.context.getEnvironment());
	this.context.refresh();
	assertThat(countBeans(RESOURCE_SERVER_CONFIG)).isEqualTo(1);
	assertThat(countBeans(AUTHORIZATION_SERVER_CONFIG)).isEqualTo(0);
	assertThat(countBeans(UserApprovalHandler.class)).isEqualTo(0);
	assertThat(countBeans(DefaultTokenServices.class)).isEqualTo(1);
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:15,代码来源:OAuth2AutoConfigurationTests.java


示例5: get

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
@Override
public T get(Object key) {
	if (!this.delegate.containsKey(key) && key instanceof String) {
		T entry = BeanUtils.instantiateClass(entryClass);
		Binder binder = new Binder(ConfigurationPropertySources.get(environment),new PropertySourcesPlaceholdersResolver(environment),this.conversionService);
		binder.bind(defaultsPrefix, Bindable.ofInstance(entry));
		this.delegate.put((String) key, entry);
	}
	return this.delegate.get(key);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:11,代码来源:EnvironmentEntryInitializingTreeMap.java


示例6: put

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
@Override
public T put(String key, T value) {
	// boot 2 call this first
	Binder binder = new Binder(ConfigurationPropertySources.get(environment),new PropertySourcesPlaceholdersResolver(environment),this.conversionService);
	binder.bind(defaultsPrefix, Bindable.ofInstance(value));
	return this.delegate.put(key, value);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:8,代码来源:EnvironmentEntryInitializingTreeMap.java


示例7: getFirstNonLoopbackHostInfo

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
private HostInfo getFirstNonLoopbackHostInfo(ConfigurableEnvironment environment) {
	InetUtilsProperties target = new InetUtilsProperties();
	ConfigurationPropertySources.attach(environment);
	Binder.get(environment).bind(InetUtilsProperties.PREFIX,
			Bindable.ofInstance(target));
	try (InetUtils utils = new InetUtils(target)) {
		return utils.findFirstNonLoopbackHostInfo();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:10,代码来源:HostInfoEnvironmentPostProcessor.java


示例8: setupContext

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
private void setupContext(Class<?>... config) {
	ConfigurationPropertySources.attach(this.context.getEnvironment());
	this.context.register(PropertyPlaceholderAutoConfiguration.class, EurekaDiscoveryClientConfiguration.class);
	for (Class<?> value : config) {
		this.context.register(value);
	}
	this.context.register(TestConfiguration.class);
	this.context.refresh();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:10,代码来源:EurekaClientAutoConfigurationTests.java


示例9: resolverSetting

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
protected <T> T resolverSetting(Class<T> clazz, MutablePropertySources propertySources) {
  return new Binder(ConfigurationPropertySources.from(propertySources))
      .bind("loc", Bindable.of(clazz))
      .orElseThrow(() -> new FatalBeanException("Could not bind DataSourceSettings properties"));
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:6,代码来源:LocBaseAutoConfiguration.java


示例10: getClientProperties

import org.springframework.boot.context.properties.source.ConfigurationPropertySources; //导入依赖的package包/类
private ClientProperties getClientProperties(ConditionContext context) {
    Iterable<ConfigurationPropertySource> sources = ConfigurationPropertySources.get(context.getEnvironment());
    ClientProperties clientProperties = new ClientProperties();
    new Binder(sources).bind("spring.boot.admin.client", Bindable.ofInstance(clientProperties));
    return clientProperties;
}
 
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:7,代码来源:SpringBootAdminClientEnabledCondition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RealVectorFormat类代码示例发布时间:2022-05-22
下一篇:
Java SimpleUnivariateValueChecker类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap