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;

    }

  • 相关阅读:
    ssm框架配置文件
    接口调用post请求参数在body中
    mysql三种连接方式
    jwt认证登录
    JWT工具类
    token的创建及解析
    IIS目录
    C# 增加多个分部类
    计算机知识
    Kibana 的安装(Windows版本)
  • 原文地址:https://www.cnblogs.com/sharpest/p/6255963.html
Copyright © 2011-2022 走看看