fix autowired

This commit is contained in:
白茶清欢 2025-06-05 21:23:12 +08:00
parent a26af73e44
commit bc7c9cac3e
2 changed files with 2 additions and 5 deletions

View File

@ -16,7 +16,6 @@ import java.util.Map;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知属性字段
@RequestScope
public class RuntimeContext implements Serializable {
@JsonProperty(RecordField.REQUEST_ID)
private String requestId; // 本次请求request id
@ -43,7 +42,7 @@ public class RuntimeContext implements Serializable {
// 序列化
@Override
public String toString() {
public String toString() throws RuntimeException {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(this);

View File

@ -32,8 +32,6 @@ import java.util.Map;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class RequestInitFilter extends HttpFilter {
@Autowired
private ObjectFactory<RuntimeContext> requestScopedBeanFactory;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@ -45,7 +43,7 @@ public class RequestInitFilter extends HttpFilter {
@Override
public void doFilter(HttpServletRequest httpServletRequest, HttpServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
RuntimeContext runtimeContext = requestScopedBeanFactory.getObject();
RuntimeContext runtimeContext = new RuntimeContext();
setBaseInfo(httpServletRequest, runtimeContext); // 设置基础信息
setRequestQuery(runtimeContext.getRequestInfo()); // 设置请求query信息
setRequestBody(runtimeContext.getRequestInfo()); // 设置请求Body