grails.war.resources = { stagingDir, args ->
copy(todir: "${stagingDir}/WEB-INF/classes/spring") {
fileset(dir:"grails-app/conf/spring") {
include(name: "datasourceDefinitions.groovy")
exclude(name: "resources.groovy")
}
}
}
我在grails-app / conf / spring中添加了datasourceDefinitions.groovy。 请帮忙。
答案 0 :(得分:1)
问题是由于Spring bean配置文件被移动到WAR文件内的文件夹“WEB-INF / classes / spring /”(确保文件打包在.war中)。正如我所做的那样是在resources.groovy中找到资源路径。
def loadFromFile = { name ->
importBeans("file:grails-app/conf/spring/"+name)
}
def loadFromWar = { name ->
def resource = application.parentContext.getResource("WEB-INF/classes/spring/"+name)
loadBeans(resource)
}
def loadResource = application.isWarDeployed() ? loadFromWar : loadFromFile
loadResource "datasourceDefinitions.groovy"
loadResource "anotherBean.groovy"