之前,我在_Events.groovy中有这个:
eventClasspathStart = {
addResourceBundlesToClasspath()
}
然而,当我部署为战争时,这不会被解雇。如何将目录添加到需要包含在战争中的类路径中?
答案 0 :(得分:4)
您可以在BuildConfig.groovy中配置战争中包含的文件 / WEB-INF中的任何内容都应该在类路径中被选中
// This closure is passed the command line arguments used to start the
// war process.
grails.war.copyToWebApp = { args ->
fileset(dir:"web-app") {
include(name: "js/**")
include(name: "css/**")
include(name: "WEB-INF/**")
}
// This closure is passed the location of the staging directory that
// is zipped up to make the WAR file, and the command line arguments.
// Here we override the standard web.xml with our own.
grails.war.resources = { stagingDir, args ->
copy(file: "grails-app/conf/custom-web.xml", tofile: "${stagingDir}/WEB-INF/web.xml")
}
来自http://grails.org/doc/latest/guide/17.%20Deployment.html
您还可以使用grails.war.dependencies在BuildConfig中指定依赖项 在战争中包括额外的文库
def deps = [
"hibernate3.jar",
"groovy-all-*.jar",
"standard-${servletVersion}.jar",
"jstl-${servletVersion}.jar",
"oscache-*.jar",
"commons-logging-*.jar",
"sitemesh-*.jar",
"spring-*.jar",
"log4j-*.jar",
"ognl-*.jar",
"commons-*.jar",
"xstream-1.2.1.jar",
"xpp3_min-1.1.3.4.O.jar" ]
grails.war.dependencies = {
fileset(dir: "libs") {
deps.each { pattern ->
include(name: pattern)
}
}
}`