【发布时间】:2016-03-05 06:38:00
【问题描述】:
我正在将 Grails 2.5 应用程序迁移到 Grails 3.0.9,但在读取 grails-app/init/BootStrap.groovy 中的类路径资源时遇到了一些问题。
在 Grails 2.5.x 中,当将资源文件放入与 BootStrap.groovy 相同的文件夹时,可以使用 Spring ClassPathResource 访问资源(例如文本文件)
def file1 = new ClassPathResource('my-textfile.txt').file
在 Grails 3 中,当我使用 grails run-app 启动我的应用程序时,它可以工作。所有资源均取自src/main/resources。但是,如果我使用 IntelliJ 中的 Spring Boot Application(位于 /grails-app/init/a/b/Application.groovy)类启动应用程序,BootStrap.groovy 将不再找到资源。
在使用Application.groovy 启动应用程序时,有谁知道如何在 Grails 3.0.9 中的BootStrap.groovy 中访问这些文件?
【问题讨论】:
标签: grails grails-3.0 grails-3.0.9