我的 Dom4j 代码做错了什么?

What am I doing wrong with my Dom4j Code?

大家好,我正在为我的项目加载 class,从 xml 文件加载和提取信息。我一直在网上关注一些指南,但我 运行 遇到了错误 java.lang.NoClassDefFoundError:org/jaxen/JaxenException。我知道代码正在查找保存文件,因为我可以打印出名称。但是当我试图提取信息时,我得到了那个错误。下面是代码片段,如果其中没有错误,请告诉我,我会 post 更多。

public void LoadProjects()
    {
        try
        {
            Files.walk(Paths.get("D:/workspace/Project Program/Projects/")).forEach(filePath ->
            {
                if(Files.isRegularFile(filePath))
                {
                    System.out.println("Testing");
                    try 
                    {
                        SAXReader reader = new SAXReader();
                        Document document = reader.read(filePath.toFile());
                        System.out.println(document.getName());
                        Node node = document.selectSingleNode("///Project/Info");
                        //String name = node.valueOf("@Name");
                        //String projNum = node.valueOf("@ProjectNumber");
                        //node = document.selectSingleNode("//Project/Dates");
                        //String dueBy = node.valueOf("@DueBy");
                        //CButton temp = new CButton(name, projNum, dueBy);
                        //Console.console.AddToList(temp);
                    } 
                    catch (Exception e) 
                    {
                        e.printStackTrace();
                    }
                }
            });
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

您是否将 jaxen jar 添加到您的服务器库中?

到目前为止,您的代码似乎是正确的,但请从一开始就添加尽可能多的信息。

如果你使用的是 maven:

<dependency>
    <groupId>jaxen</groupId>
    <artifactId>jaxen</artifactId>
    <version>1.1.1</version>
</dependency>