Search in sources :

Example 16 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project Asqatasun by Asqatasun.

the class PersistenceConfigTest method propertySourcesPlaceholderConfigurer.

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
    yaml.setResources(new ClassPathResource("application-test.yml"));
    propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
    return propertySourcesPlaceholderConfigurer;
}
Also used : YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 17 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project cas by apereo.

the class CasCoreConfigurationUtils method loadYamlProperties.

/**
 * Load yaml properties map.
 *
 * @param resource the resource
 * @return the map
 */
public static Map<String, Object> loadYamlProperties(final Resource... resource) {
    val factory = new YamlPropertiesFactoryBean();
    factory.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE);
    factory.setResources(resource);
    factory.setSingleton(true);
    factory.afterPropertiesSet();
    return (Map) factory.getObject();
}
Also used : lombok.val(lombok.val) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) Map(java.util.Map)

Aggregations

YamlPropertiesFactoryBean (org.springframework.beans.factory.config.YamlPropertiesFactoryBean)17 Properties (java.util.Properties)6 Bean (org.springframework.context.annotation.Bean)5 ByteArrayResource (org.springframework.core.io.ByteArrayResource)5 Resource (org.springframework.core.io.Resource)4 PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)3 FileSystemResource (org.springframework.core.io.FileSystemResource)3 Map (java.util.Map)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 lombok.val (lombok.val)1 OperationException (org.apache.servicecomb.config.kie.client.exception.OperationException)1 ValueType (org.apache.servicecomb.config.kie.client.model.ValueType)1 Environment (org.springframework.cloud.config.environment.Environment)1 PropertySource (org.springframework.cloud.config.environment.PropertySource)1 EncodedResource (org.springframework.core.io.support.EncodedResource)1