Java 类org.springframework.boot.env.YamlPropertySourceLoader 实例源码

项目:eds    文件:EdsCamelConfig.java   
@Bean
@Order(-1)
PropertySource dispacherPropertySource() throws IOException {
    YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
    // profile null is default
    PropertySource propertySource =
            loader.load("dispachers", new ClassPathResource("dispatch.yml"),null);
    env.getPropertySources().addLast(propertySource);
    return propertySource;
}
项目:KitchenSink    文件:ApplicationConfig.java   
@Bean
public PropertySource<?> yamlPropertySourceLoader() throws IOException {
    YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
    PropertySource<?> applicationYamlPropertySource = loader.load(
            "application.yml", new ClassPathResource("application.yml"),"default");
    return applicationYamlPropertySource;
}
项目:eds    文件:EdsCamelConfig.java   
@Bean
@Order(-1)
PropertySource consumerPropertySource() throws IOException {
    YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
    PropertySource propertySource =
            loader.load("consumers", new ClassPathResource("consumer.yml"),null);
    env.getPropertySources().addLast(propertySource);
    return propertySource;
}
项目:fiat    文件:YamlFileApplicationContextInitializer.java   
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
  try {
    Resource resource = applicationContext.getResource("classpath:application.yml");
    YamlPropertySourceLoader sourceLoader = new YamlPropertySourceLoader();
    PropertySource<?> yamlTestProperties = sourceLoader.load("yamlTestProperties", resource, null);
    applicationContext.getEnvironment().getPropertySources().addLast(yamlTestProperties);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:spring-hocon-property-source    文件:HoconPropertySourceLoaderTest.java   
@Test
public void propertyParseIsEqualToYaml() throws Exception {
    HoconPropertySourceLoader hoconLoader = new HoconPropertySourceLoader();
    YamlPropertySourceLoader yamlLoader = new YamlPropertySourceLoader();

    EnumerablePropertySource hoconParse = loadProperties(hoconLoader, "/application.conf");
    EnumerablePropertySource yamlParse = loadProperties(yamlLoader, "/application.yaml");

    verifyPropertyKeysAreSame(hoconParse, yamlParse);
    verifyPropertyValuesAreSame(hoconParse, yamlParse);
}
项目:SimpleRedisCrud    文件:ApplicationConfiguration.java   
/**
 * Yaml property source loader.
 *
 * @return the property source
 * @throws IOException Signals that an I/O exception has occurred.
 */
@Bean
public PropertySource<?> yamlPropertySourceLoader() throws IOException {
    YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
    PropertySource<?> applicationYamlPropertySource = loader.load("application.yml",
            new ClassPathResource("application.yml"), "default");
    return applicationYamlPropertySource;
}
项目:onetwo    文件:BootUtils.java   
public static PropertySource<?> loadYaml(String classpath){
    YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
    try {
        PropertySource<?> props = loader.load(classpath, SpringUtils.newClassPathResource(classpath), null);
        return props;
       } catch (IOException e) {
        throw new BaseException("load yaml file error: " + classpath);
       }
}
项目:onetwo    文件:YamlPropertySourceLoaderTest.java   
@Test
public void test() throws Exception{
    YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
    PropertySource<?> props = loader.load("application", SpringUtils.newClassPathResource("application.yaml"), null);
    Object env = props.getProperty("spring.profiles.active");
    System.out.println("env: " + env);
    env = props.getProperty("server.port");
    System.out.println("port: " + env);
}
项目:taxii-log-adapter    文件:YamlFileApplicationContextInitializer.java   
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    try {
        Resource resource = applicationContext.getResource("classpath:/config/application.yml");
        YamlPropertySourceLoader sourceLoader = new YamlPropertySourceLoader();
        PropertySource<?> yamlTestProperties = sourceLoader.load("application.yml", resource, null);
        applicationContext.getEnvironment().getPropertySources().addLast(yamlTestProperties);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:spring-cloud-cli    文件:Deployer.java   
private PropertySource<?> loadPropertySource(Resource resource, String path) {
    if (resource.exists()) {
        try {
            PropertySource<?> source = new YamlPropertySourceLoader().load(path,
                    resource, null);
            if (source != null) {
                logger.info("Loaded YAML properties from: " + resource);
            }
            return source;
        }
        catch (IOException e) {
        }
    }
    return null;
}
项目:MicroServiceProject    文件:GraphDatabaseConfiguration.java   
@Bean
public static YamlPropertySourceLoader yamlPropertySourceLoader()             {
    return new YamlPropertySourceLoader();
}
项目:MicroServiceProject    文件:GraphDatabaseConfiguration.java   
@Bean
public static YamlPropertySourceLoader yamlPropertySourceLoader()             {
    return new YamlPropertySourceLoader();
}
项目:spring-cloud-polyglot-persistence-example    文件:GraphDatabaseConfiguration.java   
@Bean
public static YamlPropertySourceLoader yamlPropertySourceLoader()             {
    return new YamlPropertySourceLoader();
}