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特殊字符转换表格如下,仅供参考

符号 转移符 说明
> > 大于
< &lt; 小于
>= &gt;= 大于等于
<= &lt;= 小于等于
& &amp;
&apos; 单引号
" &quot; 双引号

或者采用 <![CDATA[]]> 装饰
例如:

id <![CDATA[>=]]> #{id}     // id>=#{id}
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐