gpt4 book ai didi

java - Spring 异步: How to call spring hateoas ControllerLinkBuilder inside Async method

转载 作者:行者123 更新时间:2023-12-02 14:52:00 25 4
gpt4 key购买 nike

我在 spring Async 方法中调用 ControllerLinkBuilder.linkTo 方法,但它无法找到当前请求。

service.setUrl(linkTo(Controller.class, Controller.METHOD_GET,
headers.getFirst(HEADER_SOURCE), id).toString());

异常:

java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Could not find current request via RequestContextHolder
Caused by: java.lang.IllegalStateException: Could not find current request via RequestContextHolder

最佳答案

作为 _Manan 响应的补充,您可以在属性文件上将属性继承设置为 true。请添加以下行:

spring.freemarker.request-context-attribute=true

关于java - Spring 异步: How to call spring hateoas ControllerLinkBuilder inside Async method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35366655/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com