今天在一次查询中,发生了一个非法参数异常,提示

Mapped Statements collection does not contain value for cn.edu.sgu.www.mapper.CommentImageMapper.selectByCommentId

一般看到Mapped Statements collection does not contain value for xxx类似的提示就是找不到xxx对应的方法,检查方法是否存在、包名是否正确,这里的问题就是包名不正确导致的。

package cn.edu.sgu.www.fresheveryday.mapper;import cn.edu.sgu.www.fresheveryday.pojo.entity.Comment;
import cn.edu.sgu.www.fresheveryday.pojo.vo.CommentVO;
import cn.edu.sgu.www.fresheveryday.pojo.vo.UserSimpleVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;import java.util.List;@Repository
public interface CommentMapper extends BaseMapper<Comment> {/*** 通过商品id查询评论* @param productId 商品id* @return List<CommentVO>*/@Select("select id, content, type, user_id, comment_id, created from comment where product_id = #{productId}")@Result(column = "id", property = "id")@Result(column = "comment_id", property = "commentId")@Result(column = "id", property = "images",many = @Many(select = "cn.edu.sgu.www.mapper.CommentImageMapper.selectByCommentId"))@Result(column = "user_id", property = "user", javaType = UserSimpleVO.class,one = @One(select = "cn.edu.sgu.www.fresheveryday.mapper.UserMapper.selectSimpleUserById"))List<CommentVO> selectByProductId(int productId);
}

这里是因为少了一层fresheveryday包,修改之后的代码能正常运行

package cn.edu.sgu.www.fresheveryday.mapper;import cn.edu.sgu.www.fresheveryday.pojo.entity.Comment;
import cn.edu.sgu.www.fresheveryday.pojo.vo.CommentVO;
import cn.edu.sgu.www.fresheveryday.pojo.vo.UserSimpleVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;import java.util.List;@Repository
public interface CommentMapper extends BaseMapper<Comment> {/*** 通过商品id查询评论* @param productId 商品id* @return List<CommentVO>*/@Select("select id, content, type, user_id, comment_id, created from comment where product_id = #{productId}")@Result(column = "id", property = "id")@Result(column = "comment_id", property = "commentId")@Result(column = "id", property = "images",many = @Many(select = "cn.edu.sgu.www.fresheveryday.mapper.CommentImageMapper.selectByCommentId"))@Result(column = "user_id", property = "user", javaType = UserSimpleVO.class,one = @One(select = "cn.edu.sgu.www.fresheveryday.mapper.UserMapper.selectSimpleUserById"))List<CommentVO> selectByProductId(int productId);
}

好了,文章就分享到这里了,感谢阅读~

Mapped Statements collection does not contain value for xxx问题解决方法相关推荐

  1. 解决Mybatis查询错误:Mapped Statements collection does not contain value for xxx

    前言 新手在使用mybatis注解开发的时候,往往容易出现各种错误. 上述提到的"Mapped Statements collection does not contain value fo ...

  2. Mapped Statements collection does not contain value for XXX错误

    一个不该犯的错误 怎么说呢,这个bug报的实在太降低水平了,一是本就不该犯这个bug,二是这个bug竟然找了这么久.... Mapped Statements collection does not ...

  3. Mapped Statements collection does not contain value for TaskMapper.selectByPrimaryKey

    Mapped Statements collection does not contain value for后面是什么类什么方法之类的: 错误原因有几种: 1.mapper.xml中没有加入name ...

  4. Mapped Statements collection does not contain value for 之运行异常原因

    Mapped Statements collection does not contain value for 之运行异常原因 参考文章: (1)Mapped Statements collectio ...

  5. Spring Boot + Mybatis——RowBoundsPlugin造成的[Mapped Statements collection already contains value]解决方案

    基本概念 RowBoundsPlugin:通过ResultSet的游标实现的分页查询插件,容易出现性能问题 <plugin type="org.mybatis.generator.pl ...

  6. 解决Spring Boot报错Mapped Statements collection already contains value for...Error while adding the mapp

    解决Spring Boot报错Mapped Statements collection already contains value for...Error while adding the mapp ...

  7. mybatis报错:java.lang.IllegalArgumentException: Mapped Statements collection does not contain

    在做mybatis案例的时候发现了一个问题,报错如下: org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...

  8. mybatis xml文件 id冲突错误 findUserIDById is ambiguous in Mapped Statements collection

    Error querying database.  Cause: java.lang.IllegalArgumentException: findUserIDById is ambiguous in ...

  9. java.lang.IllegalArgumentException: Mapped Statements collection already contains value for ...

    java.lang.IllegalArgumentException: Mapped Statements collection already contains value for: 这个一般是参数 ...

最新文章

  1. Applese 的回文串(加一个字符的回文)
  2. 303. Range Sum Query - Immutable
  3. 分类与数值预测是预测问题的两种主要类型
  4. 互联网晚报 | 12月23日 星期四 | 芒果TV将上调会员价格;小红书宣布月活达2亿;荣耀首款折叠旗舰荣耀MagicV官宣...
  5. Shell离线脚本安装mysql、更新密码
  6. 测试方案_在线式UPS电源测试方案
  7. python常用代码入门-最全Python算法实现资源汇总!
  8. ORMLite的使用
  9. python相机标定
  10. su组件在什么窗口_动态组件:你坐好,我让SU模型自己开门
  11. 【Xamarin挖墙脚系列:mac 终端 常用命令+Mac OS X的快捷键+beamoff 】
  12. 扫描仪上显示服务器连接错误代码,扫描仪 常见问题解决方法
  13. 苹果id无法登陆_《英雄联盟手游》苹果id和拳头账户合并教程 苹果id如何绑定拳头账号...
  14. python 绝对值_Python绝对值– abs()
  15. Unity Shader - shader forge - #pragma only_renderers 和 exclude_renderers - 导致像素全黑
  16. 专利证书下载-不是标准的IE浏览器-解决办法
  17. cmt obm odm 代工模式oem_ODM/OEM/OBM的区别
  18. Kubernetes(k8s)四、Pod生命周期(初始化容器的应用,探针liveness、readliness应用,)
  19. 国开教育学形考任务2试题1试题及答案
  20. 做事的常识 书籍梗概 小仓广

热门文章

  1. 基于Python和OpenCV的面积计算
  2. 如何使用 Solidity 创建 NFT
  3. ORA-00942问题处理
  4. 新传专业需要计算机二级吗,大学生有必要去考取计算机二级证书吗?
  5. MySQL数据库的初始化和常见的简单命令
  6. EasyX简单实用的操作教程
  7. 锐捷STP生成树配置
  8. hive数据类型及转换
  9. Linux桌面环境基本介绍
  10. springboot操作cookie