Caused by: org.xml.sax.SAXParseException: 外部 DTD: 无法读取外部 DTD 'mybatis-generator-config_1_0.dtd'

1.环境:

  JDK 1.8

  IntelliJ IDEA 2019.3.2 (Community Edition)

  Build #IC-193.6015.39, built on January 21, 2020
  Runtime version: 11.0.5+10-b520.30 amd64

2.现象:

  添加 mybatis 的 generatorConfig.xml 后报错

Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 67; 外部 DTD: 无法读取外部 DTD ‘mybatis-generator-config_1_0.dtd‘, 因为 accessExternalDTD 属性设置的限制导致不允许 ‘http‘ 访问。
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:263) ~[mybatis-3.5.3.jar:3.5.3]
    at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:127) ~[mybatis-3.5.3.jar:3.5.3]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:80) ~[mybatis-3.5.3.jar:3.5.3]
    at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:592) ~[mybatis-spring-2.0.3.jar:2.0.3]
    ... 70 common frames omitted
Caused by: org.xml.sax.SAXParseException: 外部 DTD: 无法读取外部 DTD ‘mybatis-generator-config_1_0.dtd‘, 因为 accessExternalDTD 属性设置的限制导致不允许 ‘http‘ 访问。
    at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1471) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1148) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1040) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:943) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:541) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246) ~[na:na]
    at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339) ~[na:na]
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:261) ~[mybatis-3.5.3.jar:3.5.3]
    ... 73 common frames omitted

3.解决方法:

  百度到的

  解决方法一:

    Fetch external resource 到本地 如:https://blog.csdn.net/qq_35598865/article/details/88936975

  解决方法二:

    修改javax.xml.accessExternalSchema的值 如:https://blog.csdn.net/dingshuo168/article/details/103317453

在你的%JAVA_HOEE%\jre\lib\ 目录下,新建一个文件jaxp.properties,内容:

javax.xml.accessExternalSchema=all
javax.xml.accessExternalDTD=all

就可以解决了

尝试之后都没用。

解决方法:

  报错时候的位置。

不报错的位置。

修改了一下generatorConfig.xml的位置,程序就不报错了。

Caused by: org.xml.sax.SAXParseException: 外部 DTD: 无法读取外部 DTD 'mybatis-generator-config_1_0.dtd'

原文地址:https://www.cnblogs.com/Alex-Zeng/p/12269584.html

时间: 2024-10-13 14:10:38

Caused by: org.xml.sax.SAXParseException: 外部 DTD: 无法读取外部 DTD 'mybatis-generator-config_1_0.dtd'的相关文章

Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in

1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from file [E:\Ecl

Caused by: org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 84; 对实体 &quot;characterEncoding&quot;

1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from class path

Caused by: org.xml.sax.SAXParseException; lineNumber: 28; columnNumber: 81;

1.错误描述 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 28 in XML document from class path

Caused by: org.xml.sax.SAXParseException: The reference to entity &quot;characterEncoding&quot; must end with the &#39;;&#39; delimiter.

at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)    at com.sun.org.apache.xerces.internal.impl.XMLError

Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed charac

启动tomcat后,console报错如下: Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup. 由于这种错误都犯了几次,现在把问题记录下来. 第一种产生的原因是:sql中的大于号(>)或(<)小于号没有进行转义. XML只有5个转义符:<,>,&,",?;的转义字符分别如下:

Caused by: org.xml.sax.SAXParseException: 文件提前结束。

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.2019-05-11 12:24:20.657 ERROR 59648 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans

坑爹的Hibernate 映射文件错误提示org.xml.sax.SAXParseException

今天整整一个上午都在和hibernate做斗争,早上一来,继续昨天的项目开发,发现spring项目不能启动,从错误中看是hibernate错误,多半是hibernate配置有错误,关键是错误提示中显示“com.mdnet.travel.core.dao.ValidCodeDAOImpl”不能注入,经过仔细查看未见异常,而且这个文件好久没有改过了.没办法把hibernate的配置改成如下配置: <bean id="sessionFactory" class="org.sp

org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。

二月 25, 2016 9:24:24 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringMvc-1' did not find a matching property. 二月 25,

Bug解决方案:org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 8; 不允许有匹配 &quot;[xX][mM][lL]&quot; 的处理指令目标

十月 17, 2016 10:14:30 下午 org.springframework.context.support.AbstractApplicationContext prepareRefresh信息: Refreshing org[email protected]2e0fa5d3: startup date [Mon Oct 17 22:14:30 CST 2016]; root of context hierarchy十月 17, 2016 10:14:30 下午 org.spring