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

前端之家收集整理的这篇文章主要介绍了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
原文链接:https://www.f2er.com/xml/296757.html

猜你在找的XML相关文章