springboot+mybatis 的org.mybatis.spring.MyBatisSystemException 解决方法

"nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: java.lang.UnsupportedOperationException\r\n### The error may exist in com/hiteamtech/uws/dao/AppsDao.java (best guess)\r\n### The error may involve com.hiteamtech.uws.dao.AppsDao.findAppInfoByUserId\r\n### The error occurred while handling results\r\n### SQL: SELECT id,app_name,create_time,app_Introduction,user_id from app_info where status = 1 and user_id =? order by id limit ?,?\r\n### Cause: java.lang.UnsupportedOperationException"

以下是我DAO层的代码

和CONTROLLER层代码

@Select("SELECT id,app_name,create_time,app_Introduction,user_id from app_info where status = 1 and user_id =#{userId} order by id limit #{page},#{pageCount}")List findAppInfoByUserId(@Param("userId")  int userId, @Param("page") int page1, @Param("pageCount") int pageCount);
@GetMapping(value = "/apps/{userId}/{page}/{pageCount}")public ResponseEntity<Map> findAppsByUserId(@PathVariable("userId") int userId, @PathVariable("page") int page, @PathVariable("pageCount") int pageCount,Map<String,Object> map){    log.debug("根据用户ID获取我的产品:"+ userId + "page:" + page+"pageCount:"+ pageCount);    map.put("appCount",iappService.findAppsCount(userId));    map.put("appInfo",iappService.findAppsByUserId(userId,page,pageCount));    return new  ResponseEntity<>(map,HttpStatus.OK);}

因为controller里返回的JSON数据是Map 所以不能用List 返回DAO

可以对DAO做以下修改

@Select("SELECT id,app_name,create_time,app_Introduction,user_id from app_info where status = 1 and user_id =#{userId} order by id limit #{page},#{pageCount}")List<Map<String,Object>> findAppInfoByUserId(@Param("userId")  int userId, @Param("page") int page1, @Param("pageCount") int pageCount);
时间: 2024-07-31 20:34:52

springboot+mybatis 的org.mybatis.spring.MyBatisSystemException 解决方法的相关文章

查询复杂对象用respsbody转换成json串时,mybatis的延迟加载报错的解决方法

在查询数据时,如果你查询的是复杂的对象需要通过respsbody转换成json串时,mybatis用的延迟加载会报以下错误: 解决方法:第一步在RequestMapping(参数中加入 produces =  "application/json")表示将功能处理方法将生产json格式的数据,此时根据请求头中的Accept进行匹配,如请求头"Accept:application/json"时即可匹配.第二步:在实体类中前面加上注解@JsonInclude(JsonIn

mybatis 批量update报语法错误解决方法

1.为什么会报语法错误 原因:在 *.xml文件内使用了循环,在mybatis中默认是不允许使用批量修改. <update id="setMaxMin" parameterType="java.util.List"> <foreach collection="list" item="item" index="index" open="" close="&quo

【问题篇】SpringBoot的properties文件不能自动提示解决方法(一)

解决方法:Eclipse中安装Spring Tools Suite(STS). 这里采用离线安装的方式. 1. 官网下载:https://spring.io/tools3/sts/all 注意:sts的版本需要与你的eclipse对应 我的eclipse是4.5.2,所以下载: 原文地址:https://www.cnblogs.com/myitnews/p/11518730.html

转载:Maven项目mybatis Invalid bound statement (not found)解决方法

在mapper代理的开发中,程序员需要遵守一些规范,mybatis才能实现mapper接口的代理对象. 它的规范如下: mapper.xml的namespace要写所映射接口的全称类名. mapper.xml中的每个statement的id要和接口方法的方法名相同 mapper.xml中定义的每个sql的parameterType要和接口方法的形参类型相同 mapper.xml中定义的每个sql的resultType要和接口方法的返回值的类型相同 mapper.xml要和对应的mapper接口在

【spring boot+mybatis】注解使用方式(无xml配置)设置自动驼峰明明转换(),IDEA中xxDao报错could not autowire的解决方法

最近使用spring boot+mybatis,使用IntelliJ IDEA开发,记录一些问题的解决方法. 1.在使用@Mapper注解方式代替XXmapper.xml配置文件,使用@Select等注解配置sql语句的情况下,如何配置数据库字段名到JavaBean实体类属性命的自动驼峰命名转换? 使用spring boot后,越来越喜欢用注解方式进行配置,代替xml配置文件方式.mybatis中也可以完全使用注解,避免使用xml方式配置mapper.(参考  springboot(六):如何优

SpringMvc错误:HTTP Status 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is n

HTTP Status 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ItemsCustom' in 'class com.mybati

HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

type Exception report message org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: description The server encountered an internal error that prevented it from fulfilling this request. excep

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping...

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='createTime', mode=IN, javaType=class java.util.Date, jdbcType=null, numericScale=nul

【异常及源码分析】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping

一.异常出现的场景 1)异常出现的SQL @Select("SELECT\n" + " id,discount_type ,min_charge, ${cardFee} AS actualDiscountPrice , discount_price AS discountPrice ,status ,name \n" + "FROM\n" + "\tuser_coupon \n" + "WHERE\n" +