Java 使用BigDecimal值发送POJO返回null
我有一个Spring佯装客户端,它正在使用POST将POJO对象发送到远程端点:Java 使用BigDecimal值发送POJO返回null,java,spring,spring-cloud,spring-cloud-feign,feign,Java,Spring,Spring Cloud,Spring Cloud Feign,Feign,我有一个Spring佯装客户端,它正在使用POST将POJO对象发送到远程端点: SaleRequestFactory obj = new SaleRequestFactory(); obj.setId(insertedTransaction.getId()); obj.setAmount(wpfRequestDTO.getAmount()); DTO: 当我尝试获取金额时,我得到: nested exception is java.lang.NullPoint
SaleRequestFactory obj = new SaleRequestFactory();
obj.setId(insertedTransaction.getId());
obj.setAmount(wpfRequestDTO.getAmount());
DTO:
当我尝试获取金额时,我得到:
nested exception is java.lang.NullPointerException: Cannot invoke "java.math.BigDecimal.doubleValue()" because the return value of "org.SaleRequestFactory.getAmount()" is null] with root cause
java.lang.NullPointerException: Cannot invoke "java.math.BigDecimal.doubleValue()" because the return value of "org.SaleRequestFactory.getAmount()" is null
当收到POST请求时,Spring是否可能未正确转换bigdecimic
?
我是否需要将值转换为
整数
,以便正确读取数字?您发送了什么BigDecimal
值?Stacktrace说你的值为空。尝试在BigDecimal
字段中添加@JsonInclude(Include.NON_NULL)
。请更新您的问题并向我们显示您发送的请求,好吗?进一步说,java.math.BigDecimal.doubleValue()调用在哪里?
nested exception is java.lang.NullPointerException: Cannot invoke "java.math.BigDecimal.doubleValue()" because the return value of "org.SaleRequestFactory.getAmount()" is null] with root cause
java.lang.NullPointerException: Cannot invoke "java.math.BigDecimal.doubleValue()" because the return value of "org.SaleRequestFactory.getAmount()" is null