Isn';grails 2.1.1的类路径上是否还有grails app/conf?

Isn';grails 2.1.1的类路径上是否还有grails app/conf?,grails,Grails,有这样的引导: 类引导{ def init={servletContext-> def file=servletContext.getResource(“ehcache.xml”) println“++++${file}” }

有这样的引导:

类引导{
def init={servletContext->
def file=servletContext.getResource(“ehcache.xml”)
println“++++${file}”
}                                                                                                                                                                                                                                          
def destroy={
}                                                                                                                                                                                                                                          
}   
应用程序在grails app/conf目录中包含
ehcache.xml
文件,但它会打印

+++空的


在引导过程中。有什么问题?

servletContext.getResource
不在类路径上查找,而是在
web app
下查找。改为尝试
grailsApplication.classLoader.getResource
(这可能需要
def grailsApplication
init
闭包之外的类级别,我不确定)

或者,将文件移动到
web-app/web-INF
,然后

servletContext.getResource('/WEB-INF/ehcache.xml')

应该可以工作。

servletContext.getResource
不在类路径上查找,而是在
web app
下查找。改为尝试
grailsApplication.classLoader.getResource
(这可能需要
def grailsApplication
init
闭包之外的类级别,我不确定)

或者,将文件移动到
web-app/web-INF
,然后

servletContext.getResource('/WEB-INF/ehcache.xml')

应该能行。

好的,艾哈迈德。谢谢你的回复。它显然显示了我现在坐在
jar:file:/home/archer/.grails/ivy cache/org.apache.camel/camel-cache/bundles/camel-cache-2.9.4.jar中的
ehcache.xml
/xm
但是如何确保
grails app/conf/ehcache.xml
在类路径上?我怀疑,因为EhChace在加载过程中没有找到它(我已经为此启用了调试)。@archer任何基于
ClassLoader.getResource
的解决方案都会为您提供它在类路径上找到的第一个匹配项,我建议您尝试将文件移动到
web app/web-INF
的方法,这样您就可以可靠地引用该特定文件。或者试着把它放到
src/java
而不是
grails-app/conf
ok谢谢。看来这是我的错。实际问题是在启动过程中似乎忽略了ehacache.xml。试图找出原因。@archer这恐怕超出了我的专业范围。如果您在这里没有得到任何其他有用的答案,请尝试Grails
user
maillist/nabble论坛。谢谢你的回复。它显然显示了我现在坐在
jar:file:/home/archer/.grails/ivy cache/org.apache.camel/camel-cache/bundles/camel-cache-2.9.4.jar中的
ehcache.xml
/xm
但是如何确保
grails app/conf/ehcache.xml
在类路径上?我怀疑,因为EhChace在加载过程中没有找到它(我已经为此启用了调试)。@archer任何基于
ClassLoader.getResource
的解决方案都会为您提供它在类路径上找到的第一个匹配项,我建议您尝试将文件移动到
web app/web-INF
的方法,这样您就可以可靠地引用该特定文件。或者试着把它放到
src/java
而不是
grails-app/conf
ok谢谢。看来这是我的错。实际问题是在启动过程中似乎忽略了ehacache.xml。试图找出原因。@archer这恐怕超出了我的专业范围。如果您在这里没有得到任何其他有用的答案,请尝试Grails
user
邮件列表/nabble论坛。