yaml格式
name: demodesc: this is descitems: - name: item desc: item desc - name: item2 desc: desc2
maven
com.github.sanjusoftware yamlbeans 1.11
bean
public class Demo{ private String name; private String desc; private Listitems; //getter setter}
转换
ClassLoader classLoader = getClass().getClassLoader(); String path = classLoader.getResource("demo.yaml").getPath(); YamlReader reader = new YamlReader(new FileReader(path)); Demo demo = reader.read(Demo.class);