gpt4 book ai didi

org.springframework.boot.env.YamlPropertySourceLoader.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 12:14:49 26 4
gpt4 key购买 nike

本文整理了Java中org.springframework.boot.env.YamlPropertySourceLoader.<init>()方法的一些代码示例,展示了YamlPropertySourceLoader.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlPropertySourceLoader.<init>()方法的具体详情如下:
包路径:org.springframework.boot.env.YamlPropertySourceLoader
类名称:YamlPropertySourceLoader
方法名:<init>

YamlPropertySourceLoader.<init>介绍

暂无

代码示例

代码示例来源:origin: okta/okta-spring-boot

private PropertySource<?> loadYaml(Resource resource, boolean required) {
  YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
  if (!resource.exists() && required) {
    throw new IllegalArgumentException("Resource " + resource + " does not exist");
  }
  if (resource.exists()) {
    try {
      List<PropertySource<?>> list = loader.load(resource.getFilename(), resource);
      return list.get(0);
    } catch (IOException ex) {
      throw new IllegalStateException("Failed to load yaml configuration from " + resource, ex);
    }
  } else {
    return new MapPropertySource("Missing "+ resource.getFilename(), Collections.emptyMap());
  }
}

代码示例来源:origin: com.okta.spring/okta-spring-sdk

private PropertySource<?> loadYaml(Resource resource, boolean required) {
  YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
  if (!resource.exists() && required) {
    throw new IllegalArgumentException("Resource " + resource + " does not exist");
  }
  if (resource.exists()) {
    try {
      List<PropertySource<?>> list = loader.load(resource.getFilename(), resource);
      return list.get(0);
    } catch (IOException ex) {
      throw new IllegalStateException("Failed to load yaml configuration from " + resource, ex);
    }
  } else {
    return new MapPropertySource("Missing "+ resource.getFilename(), Collections.emptyMap());
  }
}

代码示例来源:origin: yuboon/Aooms

public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException {
  /*if (resource == null) {
    super.createPropertySource(name, resource);
  }*/
  List<PropertySource<?>> propertySourceList = new YamlPropertySourceLoader().load(resource.getResource().getFilename(),resource.getResource());
  return propertySourceList.get(0);
}

代码示例来源:origin: spring-cloud/spring-cloud-cli

private PropertySource<?> loadPropertySource(Resource resource, String path) {
  if (resource.exists()) {
    try {
      List<PropertySource<?>> sources = new YamlPropertySourceLoader().load(path,
          resource);
      if (sources != null) {
        logger.info("Loaded YAML properties from: " + resource);
      } else if (sources == null || sources.isEmpty()){
        return null;
      }
      CompositePropertySource composite = new CompositePropertySource("cli-sources");
      for (PropertySource propertySource : sources) {
        composite.addPropertySource(propertySource);
      }
      return composite;
    }
    catch (IOException e) {
    }
  }
  return null;
}

代码示例来源:origin: org.leapframework/leap-spring-boot

private void addPropertySources(ConfigurableEnvironment env, List<Resource> resources) {
  final PropertiesPropertySourceLoader propLoader = new PropertiesPropertySourceLoader();
  final YamlPropertySourceLoader       yamlLoader = new YamlPropertySourceLoader();
  try {
    for (Resource resource : resources) {
      if (resource.getFilename().endsWith(".properties")) {
        addPropertySource(env, resource, propLoader, false);
        log.info("Load properties '{}'", resource.getDescription());
      } else if (resource.getFilename().endsWith("yml") || resource.getFilename().endsWith("yaml")) {
        addPropertySource(env, resource, yamlLoader, false);
      }
    }
  } catch (IOException e) {
    throw new UncheckedIOException(e.getMessage(), e);
  }
}

代码示例来源:origin: spinnaker/fiat

@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);
  }
 }
}

代码示例来源:origin: spring-cloud/spring-cloud-open-service-broker

@Test
public void bindMinimumValidYaml() throws Exception {
  this.context.register(ServiceBrokerPropertiesConfiguration.class);
  Resource resource = context.getResource("classpath:catalog-minimal.yml");
  YamlPropertySourceLoader sourceLoader = new YamlPropertySourceLoader();
  List<PropertySource<?>> properties = sourceLoader.load("catalog", resource);
  context.getEnvironment().getPropertySources().addFirst(properties.get(0));
  validateMinimumCatalog();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com