Caused by: org.apache.ibatis.builder.BuilderExcepti

07-25 11:03:00   来源:   评论: 点击:

今天在使用mybaitis往数据库中添加数据的时候出现了以下的错误,org apache ibatis exceptions PersistenceExce
今天在使用mybaitis往数据库中添加数据的时候出现了以下的错误,

org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession.### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 111; 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)	at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:82)	at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:66)	at com.edu.hpu.util.MyBatisUtil.getSqlSessionFactory(MyBatisUtil.java:18)	at com.edu.hpu.util.MyBatisUtil.getSqlSession(MyBatisUtil.java:38)	at com.edu.hpu.test.Test2.testAdd(Test2.java:14)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)	at java.lang.reflect.Method.invoke(Unknown Source)	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 111; 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。	at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:259)	at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:125)	at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:79)	at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:79)	... 27 moreCaused by: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 111; 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。	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.XMLErrorReporter.reportError(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)	at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:257)	... 30 more


最后发现是数据库配制出的错,之前的是这样写的,

jdbc:mysql://localhost:3306/test,

改成这样以后问题解决,

jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull。

相关热词搜索:

上一篇:【转载】禁止apache显示目录索引的常见方法(apache禁止列目录) 下一篇:09.Apache 2.4 基于端口配置多个Diango项目
分享到: 收藏