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个转义符:<,>,&,”,?;的转义字符分别如下: &lt; &gt;&amp; &quot; &apos;

第二种产生的原因是:id值重复,原因很可能是你复制一个select时候,忘记更改id值或者复制多了。

第三种产生的原因是:sql代码书写错误。可能原因是:在plsql中用常量执行正常,但是换成变量的时候可能少个括号或者逗号之类的。

第四种产生的原因是:更改后的sql文件没有及时编译到classes目录,具体原因不知。解决办法是:project-clean。如果这样还是没有编译进去,再试试如图所示(清理tomcat临时目录):

附赠详细报错信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘oldsqlSessionFactory‘ defined in class path resource [resources/datasouce/datasource.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [E:\develop_tools\apache-tomcat-7.0.59\webapps\bookService\WEB-INF\classes\resources\mybatis\old\GroupRelateMapper.xml]‘; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [E:\develop_tools\apache-tomcat-7.0.59\webapps\bookService\WEB-INF\classes\resources\mybatis\old\GroupRelateMapper.xml]‘; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:466)
    at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:340)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    ... 22 more
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:253)
    at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:122)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:75)
    at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:462)
    ... 25 more
Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
    ... 28 more
时间: 2024-10-06 00:22:52

Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed charac的相关文章

Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.

Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.    at org.apache.ibatis.parsing.XPathParser.

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: 文件提前结束。

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

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

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

Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException:

今天在把自己的项目转为maven架构的时候,居然碰到了一个很奇葩的问题具体如下: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cos-all-l

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,