gpt4 book ai didi

grails - grails 中的资源插件在文件删除时出错?

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

我在 Grails 上使用 Groovy 并且配置了资源插件。
我有这种情况:

  • 我有一个产品,它有多个图像。
  • 管理员可以删除任何图像。

  • 逻辑是,当管理员单击“删除”时,我会从文件系统中删除文件(及其拇指文件)。

    整个过程运行顺利,但过了一段时间(5-6分钟),当资源插件再次刷新它的资源时,它会抛出一个错误,“some module depends on resource [path/to/file] but the file没找到”。

    堆栈跟踪如下:
    2012-08-10 12:49:41,159 [http-8080-2] ERROR errors.GrailsExceptionResolver  - Exception occurred when processing request: [GET] /
    Stacktrace follows:
    org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <r:layoutResources>: Module [__@adhoc-files@__] depends on resource [/images/product/p312roduct/original/Candle_4.jpg] but the file cannot be found at /home/desktop2/finalWorkspace3/ds/grails-app/views/layouts/main.gsp:13
    at home_desktop2_finalWorkspace3_ds_grails_app_views_layouts_main_gsp$_run_closure1.doCall(main.gsp:13)
    at home_desktop2_finalWorkspace3_ds_grails_app_views_layouts_main_gsp$_run_closure1.doCall(main.gsp)
    at home_desktop2_finalWorkspace3_ds_grails_app_views_layouts_main_gsp.run(main.gsp:17)
    at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanityFilter.groovy:44)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:197)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:171)
    at java.lang.Thread.run(Thread.java:679)
    Caused by: java.lang.IllegalArgumentException: Module [__@adhoc-files@__] depends on resource [/images/product/p312roduct/original/Candle_4.jpg] but the file cannot be found
    at org.grails.plugin.resource.ResourceTagLib$_closure8.doCall(ResourceTagLib.groovy:463)
    at org.grails.plugin.resource.ResourceTagLib.invokeMethod(ResourceTagLib.groovy)
    at org.grails.plugin.resource.ResourceTagLib$_closure6.doCall(ResourceTagLib.groovy:387)
    ... 7 more
    2012-08-10 12:49:41,172 [http-8080-2] ERROR pages.GroovyPagesServlet - Error processing GSP: Error executing tag <r:layoutResources>: Module [__@adhoc-files@__] depends on resource [/images/product/p312roduct/original/Candle_4.jpg] but the file cannot be found at /home/desktop2/finalWorkspace3/ds/grails-app/views/layouts/main.gsp:13
    org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <r:layoutResources>: Module [__@adhoc-files@__] depends on resource [/images/product/p312roduct/original/Candle_4.jpg] but the file cannot be found at /home/desktop2/finalWorkspace3/ds/grails-app/views/layouts/main.gsp:13
    at home_desktop2_finalWorkspace3_ds_grails_app_views_layouts_main_gsp$_run_closure1.doCall(main.gsp:13)
    at home_desktop2_finalWorkspace3_ds_grails_app_views_layouts_main_gsp$_run_closure1.doCall(main.gsp)
    at home_desktop2_finalWorkspace3_ds_grails_app_views_layouts_main_gsp.run(main.gsp:17)
    at org.grails.plugin.resource.DevModeSanityFilter.doFilter(DevModeSanityFilter.groovy:44)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:197)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:171)
    at java.lang.Thread.run(Thread.java:679)
    Caused by: java.lang.IllegalArgumentException: Module [__@adhoc-files@__] depends on resource [/images/product/p312roduct/original/Candle_4.jpg] but the file cannot be found
    at org.grails.plugin.resource.ResourceTagLib$_closure8.doCall(ResourceTagLib.groovy:463)
    at org.grails.plugin.resource.ResourceTagLib.invokeMethod(ResourceTagLib.groovy)
    at org.grails.plugin.resource.ResourceTagLib$_closure6.doCall(ResourceTagLib.groovy:387)
    ... 7 more

    最佳答案

    资源插件期望模块中的底层文件不会改变。此外,任何由应用程序直接链接的静态 Assets (而不是通过模块或 标签),都被视为 ad-hoc。 , 并作为模块添加到资源上下文中。这甚至允许资源插件对这些“遗留” Assets 进行缩小、编译、缓存等。

    如果您使用文件系统来交付您的这些有些动态的 Assets ,最好将它们排除在资源插件的临时处理之外。设置配置标志 grails.resources.adhoc.excludes排除您存储这些 Assets 的任何目录。

    关于grails - grails 中的资源插件在文件删除时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11897156/

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