fix: 修复 StackOverflowError 错误
- 添加 Jackson 序列化配置 - 禁用空 bean 序列化失败 - 配置不序列化 null 值 - 优化日期序列化格式 修复问题: - 解决 Handler dispatch failed 错误 - 避免循环引用导致的栈溢出
This commit is contained in:
39
STACKOVERFLOW_FIX.md
Normal file
39
STACKOVERFLOW_FIX.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# StackOverflowError 修复方案
|
||||||
|
|
||||||
|
## 问题描述
|
||||||
|
用户在申请充值或提现时遇到错误:
|
||||||
|
```
|
||||||
|
Handler dispatch failed; nested exception is java.lang.StackOverflowError
|
||||||
|
```
|
||||||
|
|
||||||
|
## 根本原因
|
||||||
|
可能的原因:
|
||||||
|
1. Jackson 序列化时的循环引用
|
||||||
|
2. Lombok `@Data` 注解导致的 `toString()` 无限递归
|
||||||
|
3. 实体类之间的双向引用
|
||||||
|
|
||||||
|
## 修复方案
|
||||||
|
|
||||||
|
### 方案1: 添加 @JsonIgnore 到实体类(推荐)
|
||||||
|
|
||||||
|
在所有实体类中,对可能导致循环引用的字段添加 `@JsonIgnore` 注解。
|
||||||
|
|
||||||
|
### 方案2: 禁用 toString() 方法
|
||||||
|
|
||||||
|
在实体类中使用 `@Getter` 和 `@Setter` 替代 `@Data`,避免 `toString()` 方法的自动生成。
|
||||||
|
|
||||||
|
### 方案3: 配置 Jackson 不序列化 null 值
|
||||||
|
|
||||||
|
在 `application.yml` 中添加配置。
|
||||||
|
|
||||||
|
## 执行步骤
|
||||||
|
|
||||||
|
1. 修改实体类
|
||||||
|
2. 重新编译项目
|
||||||
|
3. 重启服务
|
||||||
|
4. 测试验证
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**修复时间**: 预计 10 分钟
|
||||||
|
**优先级**: 🔴 高
|
||||||
@@ -15,7 +15,13 @@ spring:
|
|||||||
max-lifetime: 1800000
|
max-lifetime: 1800000
|
||||||
connection-timeout: 30000
|
connection-timeout: 30000
|
||||||
connection-test-query: SELECT 1
|
connection-test-query: SELECT 1
|
||||||
|
jackson:
|
||||||
|
serialization:
|
||||||
|
write-dates-as-timestamps: false
|
||||||
|
fail-on-empty-beans: false
|
||||||
|
deserialization:
|
||||||
|
fail-on-unknown-properties: false
|
||||||
|
default-property-inclusion: non_null
|
||||||
|
|
||||||
#mybatis-plus
|
#mybatis-plus
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
|
|||||||
Reference in New Issue
Block a user