Java 从yml文件读取数据库配置

Java 从yml文件读取数据库配置,java,apache,apache-commons,Java,Apache,Apache Commons,我需要读取数据库配置,如url、用户名等,以便使用yml文件登录数据库 我尝试使用Apache属性配置,但我需要读取.yml文件,所以它不起作用。例如,我想读取“用户”信息,但文件中有太多的“用户”密钥。您尝试了什么?我尝试使用Apache属性配置,但我需要读取.yml文件,因此无法工作。例如,我想读取“用户”信息,但文件中有太多“用户”密钥。 <properties> <entry key="jdbc.username">user</entry&g

我需要读取数据库配置,如url、用户名等,以便使用yml文件登录数据库


我尝试使用Apache属性配置,但我需要读取.yml文件,所以它不起作用。例如,我想读取“用户”信息,但文件中有太多的“用户”密钥。

您尝试了什么?我尝试使用Apache属性配置,但我需要读取.yml文件,因此无法工作。例如,我想读取“用户”信息,但文件中有太多“用户”密钥。
<properties> 
       <entry key="jdbc.username">user</entry>
        <entry key="jdbc.password">name</entry>
   </properties>
            Properties property = new Properties();
            FileInputStream input = new FileInputStream("E:/config.xml");
            property.loadFromXML(input);

            String username = property.getProperty("jdbc.username");