【发布时间】:2021-07-19 09:08:07
【问题描述】:
我需要为 Spring MVC 中的所有请求配置默认协程上下文。例如 MDCContext(与 this 类似的问题,但对于 MVC 而不是 WebFlux)。
我尝试过的
- 挂钩 Spring - 协程代码为 here 但无法更改默认行为(需要更改
InvocableHandlerMethod.doInvoke实现) - 使用 AOP - AOP 和协程不使用 play well together
有什么想法吗?
【问题讨论】:
-
其实第1点是不对的,可以使用
WebMvcRegistrations注册自定义的RequestMappingHandlerAdapter
标签: spring spring-mvc kotlin-coroutines