【代码优化】全局:Area 在 IDEA debug 时 toString 方法报错StackOverflowError、指定 jackson 默认序列化时双向引用的前向、后向出口避免死循环报错

This commit is contained in:
YunaiV 2024-07-28 19:34:38 +08:00
parent d14868b459
commit ad22a9d516
1 changed files with 5 additions and 0 deletions

View File

@ -1,9 +1,11 @@
package cn.iocoder.yudao.framework.ip.core; package cn.iocoder.yudao.framework.ip.core;
import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.List; import java.util.List;
@ -17,6 +19,7 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString(exclude = {"parent"}) // 参见 https://gitee.com/yudaocode/yudao-cloud-mini/pulls/2 原因
public class Area { public class Area {
/** /**
@ -46,10 +49,12 @@ public class Area {
/** /**
* 父节点 * 父节点
*/ */
@JsonManagedReference
private Area parent; private Area parent;
/** /**
* 子节点 * 子节点
*/ */
@JsonManagedReference
private List<Area> children; private List<Area> children;
} }