在使用对象映射器将具有请求范围的 bean 转换为 JSON 时,我遇到了一个问题。它会出现如下异常。不确定缺少什么。我在网上找不到任何相关的资源。有人可以解释一下应该怎么做。
提前致谢。
代码行:
planInfo -> 具有请求范围的 Bean
String json = new ObjectMapper().writeValueAsString(planInfo);
例外 :
"timestampSeconds":1630567890,"timestampNanos":683000000,"severity":"ERROR","thread":"qtp133294616-216","logger":"com.signup.api.service.SignupService","message":"exception \ncom.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: jdk.internal.loader.ClassLoaders$PlatformClassLoader[\"unnamedModule\"]-\u003ejava.lang.Module[\"classLoader\"]-....
计划信息
import lombok.Data;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
@Data
@Component
@RequestScope
public class PlanInfo {
String additionalPlanDetails;
String additionalServiceCost;
String listOfAdditionalServiceIds;
String planMinutes;
String planPrice;
String totalamt;
String setUpFee;
String selectedPlanId;
String canadaProvince;
String vatAmount;
String vatPercentage;
String netTotalAmt;
String selectedIvrPlanId;
String selectedIvrPlanMinutes;
String selectedIvrPlanPrice;
String totalPlanPrice;
String totalAmtAfterDiscount;
boolean waiveSetupFee;
String planCategory;
}