Commit ad22a9d5165952ac5ff2f1eb810ee17c07983151
1 parent
d14868b4
【代码优化】全局:Area 在 IDEA debug 时 toString 方法报错StackOverflowError、指定 jackson 默认序列化时双向引用的前向、后向出口避免死循环报错
Showing
1 changed file
with
5 additions
and
0 deletions
yudao-framework/yudao-spring-boot-starter-biz-ip/src/main/java/cn/iocoder/yudao/framework/ip/core/Area.java
| 1 | 1 | package cn.iocoder.yudao.framework.ip.core; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; |
| 4 | +import com.fasterxml.jackson.annotation.JsonManagedReference; | |
| 4 | 5 | import lombok.AllArgsConstructor; |
| 5 | 6 | import lombok.Data; |
| 6 | 7 | import lombok.NoArgsConstructor; |
| 8 | +import lombok.ToString; | |
| 7 | 9 | |
| 8 | 10 | import java.util.List; |
| 9 | 11 | |
| ... | ... | @@ -17,6 +19,7 @@ import java.util.List; |
| 17 | 19 | @Data |
| 18 | 20 | @AllArgsConstructor |
| 19 | 21 | @NoArgsConstructor |
| 22 | +@ToString(exclude = {"parent"}) // 参见 https://gitee.com/yudaocode/yudao-cloud-mini/pulls/2 原因 | |
| 20 | 23 | public class Area { |
| 21 | 24 | |
| 22 | 25 | /** |
| ... | ... | @@ -46,10 +49,12 @@ public class Area { |
| 46 | 49 | /** |
| 47 | 50 | * 父节点 |
| 48 | 51 | */ |
| 52 | + @JsonManagedReference | |
| 49 | 53 | private Area parent; |
| 50 | 54 | /** |
| 51 | 55 | * 子节点 |
| 52 | 56 | */ |
| 57 | + @JsonManagedReference | |
| 53 | 58 | private List<Area> children; |
| 54 | 59 | |
| 55 | 60 | } | ... | ... |