【发布时间】:2014-03-17 19:56:22
【问题描述】:
我有一个使用私有 Grails 插件 mySearch 的主 grails 应用程序。 插件 Search 在 Search\web-app\filters.json 中有一个文件。
使用 run-app 运行应用程序时:可以使用以下命令访问资源文件:
def ressource = new File( org.codehaus.groovy.grails.plugins.GrailsPluginUtils.getPluginDirForName('mySearch')?.file?.absolutePath
+"/web-app/filters.json").text
但是应用部署在tomcat7时就不行了。
我尝试过使用pluginManager.getGrailsPlugin('mySearch')
但我无法访问资源的绝对路径。
【问题讨论】:
-
尝试添加以下内容,前提是您已设置系统属性:(grails.util.Environment.warDeployed ? System.getProperty('catalina.home') + '/webapps/myAppName/WEB-INF / : '')
-
战争不爆发就不行
-
很高兴知道。感谢您指出这一点。
-
你好,System.getProperty('catalina.home') 给了我 catalina home 的路径,而不是 webapps 根目录的路径
标签: file grails plugins private