在公司项目开始之前,根据springboot 、mybatis、Swagger2 整合了一个demo,在测试时候,遇到的问题,简单记录。之前在使用mybatis时候,没有注意到这一点。

1、错误:There is no getter for property named 'classid' in 'class java.lang.String'

2、错误场景:再代码传递参数时候,只是传递了 字符串 类型的,但是在 mapper.xml 文件中使用了类似这样的判断

如下:

注意:这种写法本身是没有问题的
<select id="getStudentById" resultMap="selectAllStudentMap" parameterType="java.lang.String">
select * from t_student
<where>
<if test="id != null and id != '' ">
id = #{id,jdbcType=VARCHAR }
</if>
</where>
</select>

因为在 dao ,service层中,传递的是对象student,<if>标签的判断是完全可以的。

但是为了测试单个字符串传递参数的情况(参数不封装到map或者对象中),这种写法就会报错,如上的错误。

解决方式,如下,使用了 “_parameter” 这个标识,如下:

<select id="getStudentById2" resultMap="selectAllStudentMap" parameterType="java.lang.String">
select * from t_student
<where>
<if test="_parameter != null and _parameter != '' ">
id = #{id,jdbcType=VARCHAR }
</if>
</where>
</select>

解决方式2::去掉<if>标签,因为这是给bean进行判断的,如下:

去掉<if>标签
<select id="getStudentById2" resultMap="selectAllStudentMap" parameterType="java.lang.String">
select * from t_student
<where>
id = #{id,jdbcType=VARCHAR }
</where>
</select>

问题解决,可以使用  Swagger2 生成的 api文档页面进行测试了。

3、参考的文档(一个问题的讨论)http://bbs.csdn.net/topics/350253850?page=1

4、插一句嘴吧

       springboot使用起来很清爽;

       zookeeper和dubbo;

         springcloud;

         搜索;

         淘淘商城的视频;  

  

        

最新文章

  1. 2016年8月ios面试问题总结
  2. 最近Google经常打不开?
  3. C++ STL,list vector区别
  4. [java基础]分支结构(2)
  5. ActiveReports 报表应用教程 (6)---分组报表
  6. Linux cscope命令
  7. Developing a plugin framework in ASP.NET MVC with medium trust
  8. C#编写windows服务程序
  9. SLua
  10. 如何启用Service,如何停用Service
  11. KAFKA分布式消息系统[转]
  12. Java错误提示is not an enclosing class
  13. 数据结构与算法(十):红黑树与TreeMap详细解析
  14. Java笔记(day9~day10)
  15. 可编程并行接口8255A详解
  16. [转]Docker(三):Dockerfile 命令详解
  17. android展示注册进度效果源码
  18. L3-021 神坛 (30 分)
  19. Codeforces 911D. Inversion Counting (数学、思维)
  20. makefile使用.lds链接脚本以及 $@ ,$^, $,&lt; 解析【转】

热门文章

  1. LeetCode:算法特辑——二分搜索
  2. spring-boot2
  3. dev系列之gridview
  4. rail模型
  5. 【并查集】关押罪犯(BSOJ2809)
  6. 第四篇、javascript
  7. 推荐ajaxfilemanager for tiny_mce 比较完善的tiny_mce编辑器的图片上传及图片管理插件PHP版 支持中文
  8. codevs1217 借教室
  9. cocos2d-x3.0rc打包apk遇到的一些问题记录
  10. python-socket2