maven - WildFly Maven 插件 - 设置空白上下文根
问题描述
我正在使用 Maven WildFly 插件,并且在我的pom.xml
(版本是2.0.1.Final
并且路径指向本地 WildFly8.2.1.Final
服务器)中有以下内容。
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${wildfly.version}</version>
<configuration>
<jboss-home>${wildfly.path}</jboss-home>
</configuration>
</plugin>
</plugins>
</build>
应用程序正在按预期进行部署,localhost:8080/myArtifactId-myVersion
因为默认行为是使用 WAR 名称。但是,我想更改上下文根以便可以通过localhost:8080/
(即我想要一个空白的上下文根)访问应用程序。
方法一:更改 Pom 配置
我可以如下更改我的finalName
构建设置pom.xml
。
<build>
<finalName>newContextRoot</finalName>
</build>
这会正确地将 url 更新为localhost:8080/newContextRoot
. 然后我尝试将其更改为空白值。
<build>
<finalName></finalName>
</build>
但是,这会导致Value must not be empty
我的 IDE 出现错误,当我尝试构建它时会失败,说Error assembling WAR: A zip file cannot include itself
.
方法 2:更改插件配置
可能更好的解决方案是更改 Maven WildFly 插件本身的配置。在该<configuration>
部分下,我可以添加以下内容。
<name>anotherContextRoot.war</name>
这正确地将 url 更改为localhost:8080/anotherContextRoot
. 因此,我再次尝试创建一个空白名称,如下所示。
<name>.war</name>
但是,这会导致IllegalArgumentException: Empty name segment is not allowed for module
.
问题
有谁知道使上下文根为空白的适当方法?提前致谢。
解决方案
我设法弄清楚了这一点。jboss-web.xml
除了将文件添加到目录中之外,您无需执行任何操作WEB-INF
,如下所示。
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/</context-root>
<default-encoding>UTF-8</default-encoding>
</jboss-web>
这将设置上下文根并覆盖插件正在执行的操作。
希望这对其他人有帮助。
推荐阅读
- curl - 使用 Curl 和 http/3 上传文件失败:出现错误 55
- java - 如何使用 docker run 命令为 Spring Boot 应用程序覆盖 application.yml 中的 spring 属性?
- javascript - 当另一个吸气剂在 vuex 中发生变化时,我可以重新计算吸气剂吗?
- sql - BigQuery:将存储为字符串的 JSON 动态转换为结构
- php - 如何从 laravel 中的视图控制器传递数组
- javascript - 使用状态在 useffect 中不起作用并显示此错误
- c++ - 在撤消堆栈中中止撤消命令
- arrays - 从数组的某个部分减去一个数字
- reactjs - 反应路由器错误
- javascript - 在javascript中的字符串中查找多个(2)元素