Lombok的@AllArguement注解不能乱用

@AllArgsConstructor 这个注解有点坑
我在用springboot 整合mybatis 开发一个秒杀微服务时,遇到了如题的异常,原因是timestamp类型无法转化为int ,而这个异常根本驴头不对马嘴。突然看到@AllArgsConstructor 这个注解赫然在映射实体上躺着,我似乎明白了一切。

这个注解是lombok的注解,全参构造函数,加上就没有没有空参构造了。

而mapper映射,调用的空参构造,再用set方法设置参数。

不需要全参构造,就不要用这个注解,坑滴很!

后来我再次把@AllArgsConstructor加上时,报了下面的异常:

Request processing failed; nested exception is org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Cannot construct instance of com.oo.xxx.entity.Xxxx (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值