“java.net.UnknownHostException” occur when read mybatis xml file

≡放荡痞女 提交于 2019-12-06 05:56:10

It's OK by setting following features on the DocumentBuilderFactory:

    dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

eg:

    File fXmlFile = new File("c:\\mybatis.xml");
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory
            .newInstance();

    dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

    DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    Document doc = dBuilder.parse(fXmlFile);
    doc.getDocumentElement().normalize();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!