fix autowired

This commit is contained in:
zhangdeman committed 2025-06-05 21:23:12 +08:00
1 parent a26af73e44
commit bc7c9cac3e
2 files changed
+2 -5

No files matched your search

@@ -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);
@@ -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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.