fix: 修复插件启动失败——移除 ObjectMapper bean 注入

真实 Halo 2.26.1(Spring Boot 4)插件上下文中不存在
com.fasterxml.jackson.databind.ObjectMapper bean(错误截图:
ChangeCaptureManager 构造参数 3 UnsatisfiedDependency)。
改为使用 Halo API 自带的 Unstructured.OBJECT_MAPPER(Jackson 2,
与 diff 引擎的 JsonNode 类型一致),本地测试未暴露此问题,
因单测从不启动插件 Spring 上下文。
This commit is contained in:
2026-11-21 22:37:36 +08:00
parent a56bf2b9de
commit 3d31c84b48
2 changed files with 4 additions and 7 deletions
@@ -5,7 +5,6 @@ import static run.halo.operationaudit.audit.CaptureRule.WRITE_METHODS;
import static run.halo.operationaudit.audit.CaptureRule.isAuthEndpoint;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.buffer.DataBuffer;
@@ -48,7 +47,6 @@ public class ChangeCaptureManager {
private final AuditSettingProvider settingProvider;
private final SchemeManager schemeManager;
private final ReactiveExtensionClient client;
private final ObjectMapper objectMapper;
/**
* 捕获变更上下文,返回(可能包装了缓存请求体的)交换对象供后续链路继续处理。
@@ -138,8 +136,10 @@ public class ChangeCaptureManager {
}
private JsonNode parseJson(byte[] bytes) {
// 用 Halo 提供的 Unstructured 静态 mapper(Jackson 2,与 diff 树类型一致),
// 不注入 ObjectMapper bean:插件上下文(Spring Boot 4)中无该类型
try {
return objectMapper.readTree(bytes);
return Unstructured.OBJECT_MAPPER.readTree(bytes);
} catch (java.io.IOException e) {
// 非 JSON 内容或超限(StreamReadConstraints):不记字段变更,不影响记录
return null;