YAML parsing file

 YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
        yamlMapFactoryBean.setResources(new ClassPathResource("application.yml"));
        yamlMapFactoryBean.afterPropertiesSet();
        Map<String, Object> object = yamlMapFactoryBean.getObject();
        Object nameUrl = object.get("pnameUrl");

The above methods may be parsed into the file map format yml

 YamlPropertiesFactoryBean yamlPropertiesFactoryBean = new YamlPropertiesFactoryBean();
        yamlPropertiesFactoryBean.setResources(new ClassPathResource("application.yml"));
        yamlPropertiesFactoryBean.afterPropertiesSet ();
        Properties object = yamlPropertiesFactoryBean.getObject();
        Object nameUrl = object.get("pnameUrl");

In this manner the file parsed into yml (xxx.xxx.xxx) form

This method is spring comes, very easy to use can get information profile

Guess you like

Origin www.cnblogs.com/qingmuchuanqi48/p/11956476.html