2

Wildfly AS 的上下文根文件如下所示(它必须放在文件名 jboss-web.xml 中,如下所述

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>my-context</context-root>
</jboss-web>

必须将此文件及其内容复制到 WAR 文件的 WEB-INF 文件夹中。

当然我可以在构建之后手动添加这个文件并且它可以工作。但是有没有办法自动做到这一点?JHipster 中是否有任何将其内容复制到 WEB-INF 文件夹的文件夹?(添加这样的容器特定文件会很棒)

4

2 回答 2

1

您可以将文件放在 /src/main/webapp/WEB-INF 中,它会起作用。

这违背了我们“无 XML”配置的目标,但这就是 Wildfly 的工作方式……顺便说一句,我不确定你是否可以让 Spring 使用 Wildfly 工作,因为它的类加载器损坏了。

于 2014-09-17T09:41:12.763 回答
0

如果您使用 gradle,在将您的文件复制到 /src/main/webapp/WEB-INF/ 后,您必须添加 webInf { from 'src/additionalWebInf' } // 以将文件集添加到 WEB-INF 目录。在文件 gradle/war.gradle 上,文件将如下所示

apply plugin: "war"

bootWar {
    mainClassName = "com.mycompani.JhtestApp"
    includes = ["WEB-INF/**", "META-INF/**"]
    webInf { from 'src/main/webapp/WEB-INF/' } // this copy all files under this location
    //webInf { from 'src/main/webapp/WEB-INF/jboss-web.xml' } //this copy this single file
}

war {
    webAppDirName = "build/resources/main/static/"
    enabled = true
    archiveExtension = "war.original"
    includes = ["WEB-INF/**", "META-INF/**"]  
    webInf { from 'src/main/webapp/WEB-INF/' } // this copy all files under this location
    //webInf { from 'src/main/webapp/WEB-INF/jboss-web.xml' } //this copy this single file
}

我希望它对你有用。如需更多帮助,请访问 https://docs.gradle.org/current/userguide/war_plugin.html

于 2019-11-11T20:32:15.363 回答