参数值[0]与预期类型[java.lang.Integer]不匹配

前端之家收集整理的这篇文章主要介绍了参数值[0]与预期类型[java.lang.Integer]不匹配前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

有趣的问题,我传递一个int,并抱怨它不匹配类型:

org.springframework.dao.InvalidDataAccessApiUsageException:参数值[0]与预期类型[java.lang.Integer]不匹配

@Procedure(procedureName = "dbo.do_cool_stuff_to_client")
void coolClientStuff(int clientId);
@H_404_9@

它被称为如此:

public void someOtherMethod(int clientId){
  clientRepository.coolClientStuff(clientId);
}
@H_404_9@
最佳答案
事实证明,它有一些愚蠢/时髦,它真的希望我放入类类型而不是原始类型.

更改方法签名以使用Integer而不是int修复它.

@Procedure(procedureName = "dbo.do_cool_stuff_to_client")
void coolClientStuff(Integer clientId);
@H_404_9@
原文链接:https://www.f2er.com/spring/431558.html

猜你在找的Spring相关文章