直接上代码
/**
* 获取yaml文件内容
*
* @param yamlPath yaml文件路径
* @return
*/
public static Map getYamlMsg(String yamlPath) {
Map<String, Map<String, Object>> properties = new HashMap<>();
InputStream in = null;
try {
Yaml yaml = new Yaml();
in = new FileInputStream(yamlPath);
properties = yaml.loadAs(in, HashMap.class);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return properties;
}