MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 2 无效。

‘sqlSessionFactory’ defined in class path resource [spring-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [E:\ssm-blog-admin\target\ssm-blog-admin\WEB-INF\classes\com\ssm\blog\dao\mapper\AdminUserMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 2 无效。

出现这个问题的原因可能是编码错误。如果工程不是utf-8的,或者从别处复制过来的xml编码和当前工程不一样,就会出现这种问题,包括xml中的注释有中文。遇到这种问题解决方案有3个:
1.把中文都删掉
2.改编码为utf-8,但改完了可能乱码或者报错,把中文重新写一遍就好了
3.把中文注释用

猜你喜欢

转载自blog.csdn.net/yyx3214/article/details/80662357