配置api无法访问xml文件

snvhrwxg  于 2021-06-04  发布在  Hadoop
关注(0)|答案(0)|浏览(262)

我创建了一个名为 Config.xml . 内容如下:

<?xml version="1.0"?>
<configuration>
    <property>
        <name>
            color
        </name>
        <value>
            yellow
        </value>
        <description>
            Color
        </description>
    </property>
</configuration>

我尝试使用以下代码访问此xml文件:

Configuration conf = new Configuration();
    conf.addResource("/Users/XXX/Documents/Config.xml");
    System.out.println(conf.get("color"));
``` `null` 正在控制台中打印。请给我建议。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题