Mybatis注解执行<foreach>提示Parameter 'item' not found. Available paramters are [...]错误


org.apache.ibatis.binding.BindingException: Parameter 'item' not found. Available parameters are [state, type, keyword, param3, list, param4, param1, param2]
	at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:204) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:45) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.executor.BaseExecutor.createCacheKey(BaseExecutor.java:219) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.executor.CachingExecutor.createCacheKey(CachingExecutor.java:146) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.6.jar:3.4.6]
	at 
@Select({"SELECT COUNT(id) FROM (",
		"SELECT 0 AS type,a.id,a.batchNumber AS number, a.warehouseTime AS operateTime, a.operator,",
		"a.modifyTime, a.consumerId,a.state,b.realname,a.houseId,c.name AS houseName",
		"FROM warehouse a",
		"LEFT JOIN consumer b ON a.consumerId = b.id",
		"LEFT JOIN storehouse c ON a.houseId = c.id",
		"WHERE 1",
//		"<if test='type != null'>",
//		"AND type = #{type}",
//		"</if>", 
//		"<if test='state != null'>",
//		"AND a.state = #{state}",
//		"</if>", 
		"<if test='list != null'>",
		"AND a.houseId IN",
		"<foreach collection='list' item='item' open='(' separator=',' close=')'>",
		"#{item}",
		"</foreach>",
		"</if>", 
//		"<if test='keyword != null'>",
//		"AND (c.houseName like #{keyword} OR a.batchNumber like #{keyword} OR b.realname like #{keyword})",
//		"</if>",
//		"UNION",
//		"SELECT 1 AS type,a.id,a.number, a.outboundTime AS operateTime, a.operator, a.modifyTime, a.consumerId,",
//		"a.state,b.realname,a.houseId,c.name AS houseName",
//		"FROM outbound a LEFT JOIN consumer b ON a.consumerId = b.id",
//		"LEFT JOIN storehouse c ON a.houseId = c.id", 
//		"WHERE 1", 

经过分析代码发现注解书写有问题没有添加<script></script>标记,添加<script></script>后可以正常解析SQL

  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值