生成订单时报的一个异常,但是对结果无影响

来源:7-6 使用本地标识减少redis请求

Crayon_1

2020-03-19

通过 debug 定位到报异常的语句发生在:

@Transactional
public OrderInfo createOrder(MiaoshaUser user, GoodsVo goods){ 
	。。。
	// 在这一句报了的时候报了一个异常(具体异常看下面)
	// orderInfo 的内容都是完好的,最终的秒杀结果也是正确的。
	orderDao.insert(orderInfo);
}

orderDao 中的插入语句是:

@Insert("insert into order_info(user_id, goods_id, goods_name, goods_count, goods_price, order_channel, status, create_date)values("
			+ "#{userId}, #{goodsId}, #{goodsName}, #{goodsCount}, #{goodsPrice}, #{orderChannel},#{status},#{createDate} )")
@SelectKey(keyColumn="id", keyProperty="id", resultType=long.class, before=false, statement="select last_insert_id()")

异常如下:org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type ‘java.lang.String’ to required type ‘long’; nested exception is java.lang.NumberFormatException: For input string: “undefined”。

我的疑问是在这里为什么报了一个转换的异常, long 类型的 id 直接就获取到了,冒了一个 undefined 的 input string 是什么鬼?

希望老师可以帮我解惑一下,谢谢老师。

写回答

1回答

若鱼1919

2020-03-19

清空下数据库 重新调用一下接口看看  这个异常是在controller那边报出来的 应该不会继续往下执行的

0
4
Crayon_1
回复
若鱼1919
okay
2020-03-20
共4条回复

Java秒杀系统方案优化 掌握海量访问通用解决方案

各种缓存/JSR303参数检

2695 学习 · 941 问题

查看课程