gpt4 book ai didi

Gradle - War task : how include into the . war file 来自特定路径的特定文件

转载 作者:行者123 更新时间:2023-12-03 04:59:27 25 4
gpt4 key购买 nike

我正在处理一个多模块项目。

以下为必填项

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com