我正在处理一个多模块项目。
以下为必填项
apply plugin: 'war'
project(':thymeleaf-02-web') {
description 'Web (HTML, JS, CSS)'
dependencies {
exportedProjects.each{
if("$it"!=":thymeleaf-02-web")
compile project("$it")
}
}
webAppDirName = 'src/main/resources'
war {
version=''
baseName = warBaseName
}
}
webAppDirName
的值与 src/main/resources
是完全强制性的,这不是 WEB-INF
的预期工作。位置,因为我正在使用 Thymeleaf
, 否则很多 @Test
方法失败,关于测试 @Controller
关于 Spring
.现在我有了 Web 应用程序所需的强制案例
web.xml
文件配置<error-page>
.它像往常一样位于 src/main/webapp/WEB-INF/
内。位置,但是当我创建 .war
文件,它被部署到 web.xml
从未考虑在内,因此不包括在内。我尝试了以下添加:
dependencies {
compile fileTree(dir: "src/main/webapp/WEB-INF/", include: 'web.xml')
runtime fileTree(dir: "src/main/webapp/WEB-INF/", include: 'web.xml')
exportedProjects.each{
if("$it"!=":thymeleaf-02-web")
compile project("$it")
}
}
但什么都没有。目前我必须手动复制/粘贴
web.xml
将文件放入已部署的 .war
文件。那么正确的配置是什么?
最佳答案
尝试使用 from()
调用您的war
堵塞:
war {
from('src/main/webapp/WEB-INF/web.xml') {
into('WEB-INF')
}
}
关于Gradle - War task : how include into the . war file 来自特定路径的特定文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50164269/