Error note – M ybatis:Cause : org.apache.ibatis.builder.BuilderException: Error creating document instance.
Project scenario: Problem Description: Cause Analysis: solution:
Project scenario:
prompt: when testing mybatis project, an error is reported: cause: org.apache.ibatis.builder.builderexception: error creating document instance. Cause: com.sun.org.apache.xerces.internal.impl.io.malformedbytesequenceexception: byte 2 of 2-byte UTF-8 sequence is invalid</ font>
Problem Description:
when running mybatis project, the following error will be reported: </ font>
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)
at MyTest.test(MyTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:263)
at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:127)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:81)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:77)
... 24 more
Cause analysis:
analysis: the main reason for this problem is that the code declared in the XML file is inconsistent with the code saved in the XML file itself
for example, your statement is & lt;?xml version=”1.0″ encoding=”UTF-8″?& gt;<However, it is encoded in ANSI format. Although there is no garbled code, the XML parser cannot parse it
the solution is to reset the consistency between the encoding and declaration when saving XML files</ font>
Solution:
Configure in pom.xml file
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Read More:
- [Solved] Mybatis Error: Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration.
- mybatis-plus calls its own selectById method and reports an error: org.apache.ibatis.binding.BindingException:
- [Solved] ibatis.builder.BuilderException: Error parsing Mapper XML: Could not resolve type alias ‘XXX‘
- [Solved] Mybatis crud insert error: org.apache.ibatis.binding.BindingException: Mapper method ‘com.liang.dao.UserMapper.addUser…
- [Solved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource‘
- [Solved] java.lang.ClassNotFoundException: org.apache.ibatis.session.SqlSession
- How to Solve org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) Error
- Java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer; error resolution
- [Solved] Mybatis uses the PageHelper paging plugin error: Could not find method on interface ibatis.executor.Executor named query.
- ### Error building SqlSession. ### The error may exist in com/itrs/mapper/UserMapper.xml ### Cause:
- Eclipse start project error: Errors occurred during the build. Errors running builder ‘Integrated External Tool Builder’ on…
- SpringBoot uses MyBatis error: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL)
- [Solved] SAX2 driver class org.apache.xerces.parsers.SAXParser not found
- [Solved] Springboot Error: org.apache.catalina.core.ContainerBase : A child container failed during start
- [Solved] Error building SqlSession. ### The error may exist in com/itrs/mapper/OrderMapper.xml
- [Solved] presto Compile Error: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check
- Shiro Error: Configuration error: No realms have been configured!
- Error when Struts2 started Tomcat: org.apache.catalina.core.StandardContext filterStart
- SpringBoot Access Clickhouse Error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdbcConverter’ defined in class path resource [***.class]
- Hive Error: FAILED: RuntimeException Error loading hooks(hive.exec.post.hooks): java.lang.ClassNotFoundException: org.apache.atlas.hive.hook.HiveHook