IDEA--Maven项目中Spring与MyBatis整合中的报错问题org.apache.ibatis.builder.BuilderException: Error parsing Mapper

本文记录了解决Spring与MyBatis整合时出现的Mapper映射错误过程。使用Spring 5.0.2.RELEASE与MyBatis 3.4.5.RELEASE版本,在配置文件解析时出现错误。通过排查发现注释中多余的#{}

2019年3月23日23:03:54

今天学习Spring与MyBatis整合时–关于Spring管理Mapper接口进行映射时发生了如下报错:
–使用版本如下

    <spring.version>5.0.2.RELEASE</spring.version>
    <mybatis.version>3.4.5.RELEASE</mybatis.version>

报错内容为

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init
 method failed; nested exception is org.springframework.core.NestedIOException: 
    Failed to parse 
    config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. 
    Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Parsing error was found in mapping #{}.
    Check syntax #{property|(expression), var1=value1, var2=value2, ...} 

大致意思为Mapper映射报错

这样我们看一下映射Mapper文件–请注意下图中的注释引用:
在这里插入图片描述
检查了好久然而并没有发现问题在哪里–百度也搜不到答案
试了好久终于发现了问题 注释下的占位符#{}也代表着一个Value
–所以上面报错的结果就会有两个var1=value1, var2=value2:

在这里插入图片描述
我们将注释下的#{}该占位符删除掉重新运行项目这样我们发现就不会报错了

可能是系统编译原因,将我们注释下的占位符也编译进去了,下次可要记住咯。
友情提示:
道路千万条,安全第一条
代码不规范,亲人两行泪

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值