本文整理汇总了Java中org.springframework.boot.env.YamlPropertySourceLoader.load方法的典型用法代码示例。如果您正苦于以下问题:Java YamlPropertySourceLoader.load方法的具体用法?Java YamlPropertySourceLoader.load怎么用?Java YamlPropertySourceLoader.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.env.YamlPropertySourceLoader
的用法示例。
在下文中一共展示了YamlPropertySourceLoader.load方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: yamlPropertySourceLoader
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
/**
* 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;
}
示例2: yamlPropertySourceLoader
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
@Bean
public PropertySource<?> yamlPropertySourceLoader() throws IOException {
YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
PropertySource<?> applicationYamlPropertySource = loader.load(
"application.yml", new ClassPathResource("application.yml"),"default");
return applicationYamlPropertySource;
}
示例3: consumerPropertySource
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
@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;
}
示例4: initialize
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
@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);
}
}
示例5: initialize
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
@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);
}
}
示例6: loadYaml
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
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);
}
}
示例7: test
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
@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);
}
示例8: dispacherPropertySource
import org.springframework.boot.env.YamlPropertySourceLoader; //导入方法依赖的package包/类
@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;
}