gpt4 book ai didi

multithreading - 在单独的线程中使用$ {resource}?

转载 作者:行者123 更新时间:2023-12-02 15:38:03 25 4
gpt4 key购买 nike

我要执行一个简单的任务!但不知道是否有可能!

我有一个实现Runnable的常规类,并且已经使用ThreadPool运行了!我想在Runnable类中执行以下操作:

    public void run() {
EventPhoto.withTransaction { status ->

EventPhoto photo = new EventPhoto(event:eventInstance)

photo.imageUrl = "${resource(dir:'images/uploads',file:image.name, absolute:true)}"
photo.thumbnailUrl = "${resource(dir:'images/uploads',file:thumb.name, absolute:true)}"
}
}

事实是,由于我的线程不在webrequest内部运行,因此出现以下错误:

java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.



所以仍然有使用$ resource()吗?

谢谢

最佳答案

Here is some information,它将向您展示如何完成您想做的事情。另请注意,它建议您所做的是不良设计。

关于multithreading - 在单独的线程中使用$ {resource}?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6999538/

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