1、把yaml读到Map里
2、把Map转换为Properties格式
第二部分转换的核心代码如下
摘自 org.springframework.beans.factory.config.YamlProcessor
private void buildFlattenedMap(Mapresult, Map source, String path) { for (Entry entry : source.entrySet()) { String key = entry.getKey(); if (StringUtils.hasText(path)) { if (key.startsWith("[")) { key = path + key; } else { key = path + "." + key; } } Object value = entry.getValue(); if (value instanceof String) { result.put(key, value); } else if (value instanceof Map) { // Need a compound key @SuppressWarnings("unchecked") Map map = (Map ) value; buildFlattenedMap(result, map, key); } else if (value instanceof Collection) { // Need a compound key @SuppressWarnings("unchecked") Collection