zoukankan      html  css  js  c++  java
  • org.dom4j.DocumentException: null Nested exception: null解决方法

    由于最近在学习使用Spring架构,经常会遇到与xml文档打交道,今天遇到了此问题,特来分享一下解决方案。

    出错原因:

    很明显是因为找不到文件路径。这个原因是因为我使用了*.clas.getResourceAsStream(xmlFilePath)来进行xml文档的路径提供。使用这个方法时,对xml文档的路径安放有一定要求,只能在当前路径下进行搜索,不能使用绝对路径和相对路径,所以安放路径不正确就会产生这个异常。

    解决方法:

    第一种:

    将xml文件放到src文件夹下即可。

    第二种:

    public static Document parse2Document(String xmlFilePath)throws Exception{

    SAXReader reader = new SAXReader();

    Document document = null;

    File f = new File(xmlFilePath);

    InputStream in = new FileInputStream();

    document = reader(in);

    return document;

    }

    原文:https://blog.csdn.net/CeasarD/article/details/48496199

  • 相关阅读:
    wenbao与powershell
    wenbao与windows
    wenbao与msf
    CCF201612-Python题解
    语不惊人死不休
    为人性僻耽佳句(一)
    Pytorch出现 raise NotImplementedError
    CNN卷积
    python字符串切片
    python----numpy(持续更新)
  • 原文地址:https://www.cnblogs.com/pingxin/p/p00007.html
Copyright © 2011-2022 走看看