Cause: org.xml.sax.SAXParseException; lineNumber: x; columnNumber: x; 元素内容必须由格式正确的字符数据或标记组成。
程序员文章站
2022-03-24 11:37:18
...
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'xxxMapper' defined in file [D:\codes\xxx\xxx\target\classes\com\xxx\xxx\mapper\xxxMapper.class]:
Unsatisfied dependency expressed through bean property 'sqlSessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]:
Factory method 'sqlSessionFactory' threw exception;
nested exception is org.springframework.core.NestedIOException:
Failed to parse mapping resource: 'file [D:\codes\xxx\xxx\target\classes\mybatis\xxxMapper.xml]';
nested exception is org.apache.ibatis.builder.BuilderException:
Error creating document instance.
Cause: org.xml.sax.SAXParseException; lineNumber: 134; columnNumber: 59; 元素内容必须由格式正确的字符数据或标记组成。
出现此错误的原因:Mybatis xml文件中sql语句有误,一般是特殊字符没有做处理。
Mybatis-Mapper特殊字符转换表格如下,仅供参考
符号 | 转移符 | 说明 |
---|---|---|
> |
> |
大于 |
< |
< |
小于 |
>= |
>= |
大于等于 |
<= |
<= |
小于等于 |
& |
& |
和 |
‘ |
' |
单引号 |
" |
" |
双引号 |
或者采用 <![CDATA[]]>
装饰
例如:
id <![CDATA[>=]]> #{id} // id>=#{id}
上一篇: jBPM开发入门指南(4)
下一篇: HDFS配置Kerberos认证