Can‘t generate mapping method with primitive return type.

2024-04-23 14:20

本文主要是介绍Can‘t generate mapping method with primitive return type.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

遇到问题:

Can't generate mapping method with primitive return type.

无法为原始返回类型生成映射方法。

解决方案:

  1. 检查注解:

    • 确保你使用了正确的注解,如@Mapper@Autowired来注入映射接口。
  2. 方法签名:

    • 确认映射方法的返回类型是原始类型(如int, double等),而不是包装类(如Integer, Double)。
  3. 使用@Mapping注解:

    • 如果需要转换特定字段,使用@Mapping注解在源对象属性和目标对象属性之间指定映射关系。
  4. 自定义转换器:

    • 创建一个实现了ResultMapTypeHandler接口的自定义类,处理原始类型的转换。
  5. 配置Mapper XML文件:

    • 对于复杂转换,可能需要在对应的Mapper XML文件中添加 <result><select> 标签以指定返回类型。
  6. 检查依赖:

    • 确保你的项目已经包含了MyBatis或MyBatis-Spring的相关库。
  7. 重新构建项目:

    • 清理并重新构建项目,确保所有改动已生效。
  8. 查阅文档:

    • 如果以上步骤无效,查阅MyBatis或相关框架的官方文档,寻找针对原始类型的支持信息。

这篇关于Can‘t generate mapping method with primitive return type.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/929033

相关文章

BD错误集锦7——在集成Spring MVC + MyBtis时使用c3p0作为数据库时报错Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatem

异常信息如下: Type Exception ReportMessage Handler dispatch failed; nested exception is java.lang.AbstractMethodError: Method com/mchange/v2/c3p0/impl/NewProxyPreparedStatement.isClosed()Z is abstractDescr

「Debug R」报错unable to find an inherited method for function是如何产生的

在一个群里看到这样一条报错,截图如下: 报错信息 当然这种问题解决起来也很快,无非就是把报错信息复制出来放在搜索引擎上,只不过你要挑选合适的搜索引擎。 百度 谷歌 必应 解决方案就是用dplyr::select。 虽然报错解决了,但是我还想着要重复出这个报错。因为只有能重复出报错,才能证明你不是运气好才解

面试题之final,finally和finalize的区别以及如果catch里面有return语句,请问finally里面的代码还会执行吗?

/*  * 面试题:  * 1:final,finally和finalize的区别  * final:最终的意思,可以修饰类,成员变量,成员方法  *         修饰类,类不能被继承  *         修饰变量,变量是常量  *         修饰方法,方法不能被重写  * finally:是异常处理的一部分,用于释放资源。  *         一般来

abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized

1,abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized 都不可以,因为abstract申明的方法是要求子类去实现的,abstract只是告诉你有这样一个接口,你要去实现,至于你的具体实现可以是native和synchronized,也可以不是,抽象方法是不关心这些事的,所以写这两个是没有意义的。然后,static方法是不会被覆

Access restriction: The type 'XXX' is not API (restriction on required library 'C:\Progra

1.问题 Eclipse 编译错误: Access restriction: The type 'xxx' is not API (restriction on required library 'C:\Progra。。。 我引入一个    import sun.misc.ProxyGenerator;  但是Eclispe编译报错,但是java的jre确实有该包。 2.解决方法

try...catch...finally块嵌入return

不论C++还是Java中,try...catch...finally语句块都是用来控制程序异常的处理,而finally块是最后一定执行的,那么现在在try...catch...块中加入了return语句,finally仍会执行吗? public class Try_Return_Final {int test(){int x = 1;try{return x;}finally{++x;}}p

Java中的continue、break和return

一、continue结束本次循环,进入下次循环 for(int i=0; i<5; i++){for(int j=0; j<5; j++){if(j == 3) continue;System.out.print("(" + i + "," + j +")"); }System.out.println();}   二、break 1、break终止本次循环 for(i

Bean named 'BService' is expected to be of type 'path1' but was actually of type 'path2'

报错: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AService': Injection of resource dependencies failed; nested exception is org.springframework.be

js中的break,continue,return

转自:  http://blog.sina.com.cn/s/blog_67aaf4440100p3zg.html 谢谢! 面向对象编程语法中我们会碰到break ,continue, return这三个常用的关键字,那么关于这三个关键字的使用具体的操作是什么呢?我们在使用这三关键字的时候需要注意和需要理解的规则是什么呢?让我们开始介绍吧:   js编程语法之break语句: br

error: the type ‘const zjloc::<lambda(const Vec2i, const Vec2i)>’

catkin_make 编译时遇到这个问题: /home/robot/ct_lio/src/ct-lio/src/common/eigen_types.h:114:20: error: the type ‘const zjloc::<lambda(const Vec2i&, const Vec2i&)>’ of ‘constexpr’ variable ‘zjloc::less_vec2i’