GVKun编程网logo

org.springframework.boot.context.properties.source.ConfigurationPropertySources的实例源码

15

想了解org.springframework.boot.context.properties.source.ConfigurationPropertySources的实例源码的新动态吗?本文将为您提供

想了解org.springframework.boot.context.properties.source.ConfigurationPropertySources的实例源码的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreatio...、org.springframework.beans.factory.config.PropertyResourceConfigurer的实例源码、org.springframework.boot.actuate.autoconfigure.ShellProperties.JaasAuthenticationProperties的实例源码、org.springframework.boot.actuate.autoconfigure.ShellProperties.KeyAuthenticationProperties的实例源码的新知识。

本文目录一览:

org.springframework.boot.context.properties.source.ConfigurationPropertySources的实例源码

org.springframework.boot.context.properties.source.ConfigurationPropertySources的实例源码

项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@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);
}
项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testCanUseClientCredentialsWithEnableoauth2client() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    this.context.register(ClientConfiguration.class,"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);
}
项目:loc-framework    文件:PrefixPropertyCondition.java   
@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));
}
项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@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);
}
项目:spring-cloud-stream    文件:EnvironmentEntryInitializingTreeMap.java   
@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);
}
项目:spring-cloud-stream    文件:EnvironmentEntryInitializingTreeMap.java   
@Override
public T put(String key,T value) {
    // boot 2 call this first
    Binder binder = new Binder(ConfigurationPropertySources.get(environment),this.conversionService);
    binder.bind(defaultsPrefix,Bindable.ofInstance(value));
    return this.delegate.put(key,value);
}
项目:spring-cloud-commons    文件:HostInfoEnvironmentPostProcessor.java   
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();
    }
}
项目:spring-cloud-netflix    文件:EurekaClientAutoConfigurationTests.java   
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();
}
项目:loc-framework    文件:LocBaseAutoConfiguration.java   
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"));
}
项目:spring-boot-admin    文件:SpringBootAdminClientEnabledCondition.java   
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;
}

Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreatio...

Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreatio...

 1 Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "local" are currently active).
 2     at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:247)
 3     at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:184)
 4     at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:42)
 5     at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat.dataSource(DataSourceConfiguration.java:56)
 6     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 7     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 8     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 9     at java.lang.reflect.Method.invoke(Method.java:498)
10     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
11     ... 116 common frames omitted

报错原因:项目的bootstrap.yml中,config-server没有配置正确(如下14行):应该配置为config-server的名字,我配置成了项目名称

 1 spring:
 2   profiles:
 3     active: local
 4   application:
 5     name: xxx-server
 6   cloud:
 7     config:       
 8       name: ${spring.application.name}
 9       profile: ${config.profile:dev}
10       username: ${myauth.config.username}
11       password: ${myauth.config.password}
12       discovery:
13         enabled: true #使用服务发现组件中的Config Server,默认false
14         service-id: config-server  #Config Server的名字,默认configserver

 

org.springframework.beans.factory.config.PropertyResourceConfigurer的实例源码

org.springframework.beans.factory.config.PropertyResourceConfigurer的实例源码

项目:spring-component-framework    文件:ContextUtils.java   
/**
 * 继承上级上下文中的属性配置器
 *
 * @param inheriting  上级上下文
 * @param context 当前上下文
 */
public static void inheritParentProperties(ApplicationContext inheriting,GenericApplicationContext context) {
    if (!(inheriting instanceof AbstractApplicationContext)) return;
    List<beanfactoryPostProcessor> processors =
            ((AbstractApplicationContext) inheriting).getbeanfactoryPostProcessors();
    for (beanfactoryPostProcessor processor : processors) {
        if (processor instanceof PropertyResourceConfigurer)
            context.addbeanfactoryPostProcessor(processor);
    }
}
项目:cloudbreak    文件:IntegrationTestConfiguration.java   
@Bean
public static PropertyResourceConfigurer propertySourcesPlaceholderConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}
项目:cloudbreak    文件:TestConfig.java   
@Bean
public static PropertyResourceConfigurer propertyResourceConfigurer() {
    return new PropertySourcesPlaceholderConfigurer();
}

org.springframework.boot.actuate.autoconfigure.ShellProperties.JaasAuthenticationProperties的实例源码

org.springframework.boot.actuate.autoconfigure.ShellProperties.JaasAuthenticationProperties的实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ShellPropertiesTests.java   
@Test
public void testBindingJaas() {
    JaasAuthenticationProperties props = load(JaasAuthenticationProperties.class,"management.shell.auth.jaas.domain=my-test-domain");
    Properties p = new Properties();
    props.applyToCrshShellConfig(p);
    assertthat(p.get("crash.auth.jaas.domain")).isEqualTo("my-test-domain");
}
项目:spring-boot-concourse    文件:ShellPropertiesTests.java   
@Test
public void testBindingJaas() {
    JaasAuthenticationProperties props = load(JaasAuthenticationProperties.class,"management.shell.auth.jaas.domain=my-test-domain");
    Properties p = new Properties();
    props.applyToCrshShellConfig(p);
    assertthat(p.get("crash.auth.jaas.domain")).isEqualTo("my-test-domain");
}
项目:contestparser    文件:ShellPropertiesTests.java   
@Test
public void testBindingJaas() {
    JaasAuthenticationProperties props = new JaasAuthenticationProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props,"shell.auth.jaas");
    binder.setConversionService(new DefaultConversionService());
    Map<String,String> map = new HashMap<String,String>();
    map.put("shell.auth.jaas.domain","my-test-domain");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

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

    assertEquals("my-test-domain",p.get("crash.auth.jaas.domain"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CrshAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = AUTH_PREFIX,name = "type",havingValue = "jaas")
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
public JaasAuthenticationProperties jaasAuthenticationProperties() {
    return new JaasAuthenticationProperties();
}
项目:spring-boot-concourse    文件:CrshAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = AUTH_PREFIX,havingValue = "jaas")
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
public JaasAuthenticationProperties jaasAuthenticationProperties() {
    return new JaasAuthenticationProperties();
}
项目:contestparser    文件:CrshAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = "shell",name = "auth",havingValue = "jaas")
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
public JaasAuthenticationProperties jaasAuthenticationProperties() {
    return new JaasAuthenticationProperties();
}

org.springframework.boot.actuate.autoconfigure.ShellProperties.KeyAuthenticationProperties的实例源码

org.springframework.boot.actuate.autoconfigure.ShellProperties.KeyAuthenticationProperties的实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ShellPropertiesTests.java   
@Test
public void testBindingKey() {
    KeyAuthenticationProperties props = load(KeyAuthenticationProperties.class,"management.shell.auth.key.path=~/.ssh/test.pem");
    Properties p = new Properties();
    props.applyToCrshShellConfig(p);
    assertthat(p.get("crash.auth.key.path")).isEqualTo("~/.ssh/test.pem");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ShellPropertiesTests.java   
@Test
public void testBindingKeyIgnored() {
    KeyAuthenticationProperties props = load(KeyAuthenticationProperties.class);
    Properties p = new Properties();
    props.applyToCrshShellConfig(p);
    assertthat(p.get("crash.auth.key.path")).isNull();
}
项目:spring-boot-concourse    文件:ShellPropertiesTests.java   
@Test
public void testBindingKey() {
    KeyAuthenticationProperties props = load(KeyAuthenticationProperties.class,"management.shell.auth.key.path=~/.ssh/test.pem");
    Properties p = new Properties();
    props.applyToCrshShellConfig(p);
    assertthat(p.get("crash.auth.key.path")).isEqualTo("~/.ssh/test.pem");
}
项目:spring-boot-concourse    文件:ShellPropertiesTests.java   
@Test
public void testBindingKeyIgnored() {
    KeyAuthenticationProperties props = load(KeyAuthenticationProperties.class);
    Properties p = new Properties();
    props.applyToCrshShellConfig(p);
    assertthat(p.get("crash.auth.key.path")).isNull();
}
项目:contestparser    文件:ShellPropertiesTests.java   
@Test
public void testBindingKey() {
    KeyAuthenticationProperties props = new KeyAuthenticationProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props,"shell.auth.key");
    binder.setConversionService(new DefaultConversionService());
    Map<String,String> map = new HashMap<String,String>();
    map.put("shell.auth.key.path","~/.ssh/test.pem");
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

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

    assertEquals("~/.ssh/test.pem",p.get("crash.auth.key.path"));
}
项目:contestparser    文件:ShellPropertiesTests.java   
@Test
public void testBindingKeyIgnored() {
    KeyAuthenticationProperties props = new KeyAuthenticationProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(props,String>();
    binder.bind(new MutablePropertyValues(map));
    assertFalse(binder.getBindingResult().hasErrors());

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

    assertNull(p.get("crash.auth.key.path"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CrshAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = AUTH_PREFIX,name = "type",havingValue = "key")
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
public KeyAuthenticationProperties keyAuthenticationProperties() {
    return new KeyAuthenticationProperties();
}
项目:spring-boot-concourse    文件:CrshAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = AUTH_PREFIX,havingValue = "key")
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
public KeyAuthenticationProperties keyAuthenticationProperties() {
    return new KeyAuthenticationProperties();
}
项目:contestparser    文件:CrshAutoConfiguration.java   
@Bean
@ConditionalOnProperty(prefix = "shell",name = "auth",havingValue = "key")
@ConditionalOnMissingBean(CrshShellAuthenticationProperties.class)
public KeyAuthenticationProperties keyAuthenticationProperties() {
    return new KeyAuthenticationProperties();
}

关于org.springframework.boot.context.properties.source.ConfigurationPropertySources的实例源码的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreatio...、org.springframework.beans.factory.config.PropertyResourceConfigurer的实例源码、org.springframework.boot.actuate.autoconfigure.ShellProperties.JaasAuthenticationProperties的实例源码、org.springframework.boot.actuate.autoconfigure.ShellProperties.KeyAuthenticationProperties的实例源码的相关信息,请在本站寻找。

本文标签: