- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.yaml.snakeyaml.Yaml.<init>()
方法的一些代码示例,展示了Yaml.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yaml.<init>()
方法的具体详情如下:
包路径:org.yaml.snakeyaml.Yaml
类名称:Yaml
方法名:<init>
[英]Create Yaml instance. It is safe to create a few instances and use them in different Threads.
[中]创建Yaml实例。创建几个实例并在不同的线程中使用它们是安全的。
代码示例来源:origin: apache/incubator-shardingsphere
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> load(final String data) {
return Strings.isNullOrEmpty(data) ? new LinkedHashMap<String, Object>() : (Map) new Yaml().load(data);
}
}
代码示例来源:origin: apache/incubator-shardingsphere
@SuppressWarnings("unchecked")
@Override
public Map<String, DataSourceConfiguration> load(final String data) {
Map<String, YamlDataSourceConfiguration> result = (Map) new Yaml().load(data);
Preconditions.checkState(null != result && !result.isEmpty(), "No available data sources to load for orchestration.");
return Maps.transformValues(result, new Function<YamlDataSourceConfiguration, DataSourceConfiguration>() {
@Override
public DataSourceConfiguration apply(final YamlDataSourceConfiguration input) {
DataSourceConfiguration result = new DataSourceConfiguration(input.getDataSourceClassName());
result.getProperties().putAll(input.getProperties());
return result;
}
});
}
}
代码示例来源:origin: pmd/pmd
public Map<String, Object> loadSidebar() throws IOException {
try (Reader reader = Files.newBufferedReader(sidebarPath, StandardCharsets.UTF_8)) {
Yaml yaml = new Yaml();
@SuppressWarnings("unchecked")
Map<String, Object> sidebar = (Map<String, Object>) yaml.load(reader);
return sidebar;
}
}
代码示例来源:origin: alibaba/jstorm
public static void LoadYaml(String confPath) {
Yaml yaml = new Yaml();
try {
InputStream stream = new FileInputStream(confPath);
conf = (Map) yaml.load(stream);
if (conf == null || conf.isEmpty() == true) {
throw new RuntimeException("Failed to read config file");
}
} catch (FileNotFoundException e) {
System.out.println("No such file " + confPath);
throw new RuntimeException("No config file");
} catch (Exception e1) {
e1.printStackTrace();
throw new RuntimeException("Failed to read config file");
}
return;
}
代码示例来源:origin: alibaba/jstorm
private static Map LoadYaml(String confPath) {
Map ret = null;
Yaml yaml = new Yaml();
try {
InputStream stream = new FileInputStream(confPath);
ret = (Map) yaml.load(stream);
if (ret == null || ret.isEmpty() == true) {
throw new RuntimeException("Failed to read config file");
}
} catch (FileNotFoundException e) {
System.out.println("No such file " + confPath);
throw new RuntimeException("No config file");
} catch (Exception e1) {
e1.printStackTrace();
throw new RuntimeException("Failed to read config file");
}
return ret;
}
代码示例来源:origin: alibaba/jstorm
public static Map loadDefinedConf(String confFile) {
File file = new File(confFile);
if (!file.exists()) {
return LoadConf.findAndReadYaml(confFile, true, false);
}
Yaml yaml = new Yaml();
Map ret;
try {
ret = (Map) yaml.load(new FileReader(file));
} catch (FileNotFoundException e) {
ret = null;
}
if (ret == null)
ret = new HashMap();
return new HashMap(ret);
}
代码示例来源:origin: alibaba/jstorm
private static Map loadYaml(String confPath) {
Map ret = new HashMap<>();
Yaml yaml = new Yaml();
InputStream stream = null;
try {
stream = new FileInputStream(confPath);
ret = (Map) yaml.load(stream);
if (ret == null || ret.isEmpty()) {
return null;
}
} catch (FileNotFoundException e) {
throw new RuntimeException("No config file");
} catch (Exception e1) {
throw new RuntimeException("Failed to read config file");
} finally {
if (stream != null) {
try {
stream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return ret;
}
代码示例来源:origin: apache/incubator-pinot
public static void main(String[] args)
throws Exception {
PerfBenchmarkDriverConf conf = (PerfBenchmarkDriverConf) new Yaml().load(new FileInputStream(args[0]));
PerfBenchmarkDriver perfBenchmarkDriver = new PerfBenchmarkDriver(conf);
perfBenchmarkDriver.run();
}
}
代码示例来源:origin: apache/incubator-dubbo
private static <T> T parseObject(String rawConfig) {
Constructor constructor = new Constructor(ConfiguratorConfig.class);
TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class);
itemDescription.addPropertyParameters("items", ConfigItem.class);
constructor.addTypeDescription(itemDescription);
Yaml yaml = new Yaml(constructor);
return yaml.load(rawConfig);
}
代码示例来源:origin: cloudfoundry/uaa
public List<UrlGroup> getUrlGroups() throws IOException {
ClassPathResource resource = new ClassPathResource("performance-url-groups.yml");
Yaml yaml = new Yaml();
List<Map<String,Object>> load = (List<Map<String, Object>>) yaml.load(resource.getInputStream());
return load.stream().map(map -> UrlGroup.from(map)).collect(Collectors.toList());
}
代码示例来源:origin: apache/incubator-dubbo
private static <T> T parseObject(String rawConfig) {
Constructor constructor = new Constructor(ConfiguratorConfig.class);
TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class);
itemDescription.addPropertyParameters("items", ConfigItem.class);
constructor.addTypeDescription(itemDescription);
Yaml yaml = new Yaml(constructor);
return yaml.load(rawConfig);
}
代码示例来源:origin: cloudfoundry/uaa
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new IllegalArgumentException("YAML file required");
}
Yaml yaml = new Yaml(new UaaConfigConstructor());
BufferedReader br = new BufferedReader(new FileReader(args[0]));
UaaConfiguration config = (UaaConfiguration) yaml.load(br);
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<UaaConfiguration>> errors = validator.validate(config);
System.out.println(errors);
}
}
代码示例来源:origin: Netflix/Priam
public void updateAutoBootstrap(String yamlFile, boolean autobootstrap) throws IOException {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(options);
@SuppressWarnings("rawtypes")
Map map = yaml.load(new FileInputStream(yamlFile));
// Dont bootstrap in restore mode
map.put("auto_bootstrap", autobootstrap);
if (logger.isInfoEnabled()) {
logger.info("Updating yaml: " + yaml.dump(map));
}
yaml.dump(map, new FileWriter(yamlFile));
}
代码示例来源:origin: apache/storm
/**
* Parse the TopologyLoadConf from a file in YAML format.
* @param file the file to read from
* @return the parsed conf
* @throws IOException if there is an issue reading the file.
*/
public static TopologyLoadConf fromConf(File file) throws IOException {
Yaml yaml = new Yaml(new SafeConstructor());
Map<String, Object> yamlConf = (Map<String, Object>)yaml.load(new FileReader(file));
return TopologyLoadConf.fromConf(yamlConf);
}
代码示例来源:origin: apache/incubator-dubbo
public static ConditionRouterRule parse(String rawRule) {
Constructor constructor = new Constructor(ConditionRouterRule.class);
Yaml yaml = new Yaml(constructor);
ConditionRouterRule rule = yaml.load(rawRule);
rule.setRawRule(rawRule);
if (CollectionUtils.isEmpty(rule.getConditions())) {
rule.setValid(false);
}
return rule;
}
代码示例来源:origin: apache/incubator-dubbo
public static ConditionRouterRule parse(String rawRule) {
Constructor constructor = new Constructor(ConditionRouterRule.class);
Yaml yaml = new Yaml(constructor);
ConditionRouterRule rule = yaml.load(rawRule);
rule.setRawRule(rawRule);
if (CollectionUtils.isEmpty(rule.getConditions())) {
rule.setValid(false);
}
return rule;
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private Map<String,?> readKubeConfig() {
String kubeConfig = System.getenv("KUBECONFIG");
Reader reader = kubeConfig == null
? getFileReaderFromDir(new File(getHomeDir(),".kube/config"))
: getFileReaderFromDir(new File(kubeConfig));
if (reader != null) {
Yaml ret = new Yaml();
return (Map<String, ?>) ret.load(reader);
}
return null;
}
代码示例来源:origin: cloudfoundry/uaa
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws Exception {
Assert.state(yaml != null, "Yaml document should not be null");
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
try {
logger.trace("Yaml document is\n" + yaml);
configuration = (T) (new Yaml(constructor)).load(yaml);
Set<ConstraintViolation<T>> errors = validator.validate(configuration);
if (!errors.isEmpty()) {
logger.error("YAML configuration failed validation");
for (ConstraintViolation<?> error : errors) {
logger.error(error.getPropertyPath() + ": " + error.getMessage());
}
if (exceptionIfInvalid) {
@SuppressWarnings("rawtypes")
ConstraintViolationException summary = new ConstraintViolationException((Set) errors);
throw summary;
}
}
} catch (YAMLException e) {
if (exceptionIfInvalid) {
throw e;
}
}
}
代码示例来源:origin: alibaba/mdrill
Yaml yaml = new Yaml();
Map ret = (Map) yaml.load(isr);
if (ret != null)
Yaml yaml = new Yaml();
Map ret = (Map) yaml.load(new InputStreamReader(resource
.openStream()));
if (ret == null)
代码示例来源:origin: alibaba/jstorm
in = getConfigFileInputStream(name, canMultiple);
if (null != in) {
Yaml yaml = new Yaml(new SafeConstructor());
Map ret = (Map) yaml.load(new InputStreamReader(in));
if (null != ret) {
return new HashMap(ret);
我正在尝试使用 Java 中的 SnakeYaml 解析 YAML 文件,并且我正在努力让它通过 setter 构建我的模型对象。我从 SnakeYaml 文档中了解到,当您使用遵循 JavaBean
我正在尝试使用 snakeyaml 将下面的 YAML 反序列化到下面的域模型中,但是我不断收到 java.lang.ClassCastException: java.util.LinkedHashM
这是我的问题。我有包含以下对的 YAML 文档: run_ID: 2010_03_31_101 当这个 get 被解析时 org.yaml.snakeyaml.constructor.SafeCons
我在程序中有以下无法更改的类结构: class Node { public String name; } class Nodes { public List nodes; } cla
我想解析 config.yaml 文件,但遇到了一些问题。 这是我的 JavaBean 代码 Oss.class: import lombok.Data; import java.util.List;
据我所知,关于 yaml 命名约定的建议似乎是遵循软件约定,因此在我的例子中是 Java。 我收到了一个具有以下语法的 yaml 文件 PERSON: NAME: John Doe 除非我从一个人
我正在尝试使用snakeyaml在java中创建YAML文件,但我无法获取我需要的格式。使用 DumperOptions.FlowStyle.BLOCK 时,某些子项的格式正确,而使用默认 Dumpe
我正在使用 SnakeYAML 作为项目的 YAML 解析器,但我不知道如何设置嵌套的键。例如,这是一个包含嵌套键的 YAML 文件。 control: advertising: enab
我正在尝试使用 snakeyaml 将下面的 YAML 反序列化到下面的域模型中,但是我不断收到 java.lang.ClassCastException: java.util.LinkedHashM
当这是我的 .yml 文件时: test1: "string1" test2: test3: "string2" 如何获取test3的值? Map yamlFile = new Yaml().lo
我正在使用snakeYaml (snakeyaml-engine-2.1) 来序列化pojo。 Atm 序列化产生以下输出 name: "OuterYamlElementName" label: "O
在列表内部,我想多次引用同一个实例对象: - text: Here is an object with some data that will allow an image to be generat
我正在尝试从纯java字符串创建一个yaml文件。但是,我创建的 yaml 文件的初始行为: |2 yaml 文件的其余部分很好,但第一行非常有趣。我的 DumperOptions 如下; Dumpe
我一直在努力设置我的配置以使用 SnakeYAML。我希望我的配置如下所示: connection: bind-ip: 0.0.0.0 plugin-port: 2011 rt
我正在尝试使用 Groovy 和 Snakeyaml 解析以下 YAML 文件(显然我已经清理了数据,但这足以证明问题): --- info: summary: Snakeyaml Issue e
我想使用 SnakeYAML(或其他解析器)解析 Docker-compose.yml。我遇到的问题是属性可以是字符串或更复杂的对象,例如 configs ,支持“短”语法和“长”语法: 简短 ver
考虑以下代码: public void testDumpWriter() { Map data = new HashMap(); data.put("NAME1", "Raj"); data.put(
我使用以下方法将对象转换为 yaml 表示(例如,我可以打印到控制台) @Nonnull private String outputObject(@Nonnull final ObjectToPrin
我的意图是使用 jackson 获得像 JSON 中那样的多态集合,也许借助标签。 我似乎无法正确配置它。 我的 yaml 文件是: !person age: 27 job: dev name: me
本文整理了Java中org.yaml.snakeyaml.Yaml类的一些代码示例,展示了Yaml类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一
我是一名优秀的程序员,十分优秀!