Undertow 和 Tomcat 的 Spring Boot .war 上下文路径 [英] Spring Boot .war context path for Undertow and Tomcat

查看:42
本文介绍了Undertow 和 Tomcat 的 Spring Boot .war 上下文路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Spring Boot 应用程序,我将其作为 .war 文件部署在现有的 Tomcat 和 Undertow(Wildfly) 容器中.如何从应用程序内配置上下文路径?

I have a Spring Boot application which I will deploy as a .war file in existing Tomcat and Undertow(Wildfly) containers. How can I configure the context path from within the application?

我知道我可以直接使用 .war 名称,但我不想这样做,因为 .war 名称包含版本信息等.

I know I can use the .war name directly, but I dont want to do that since the .war name contains version information etc.

推荐答案

来自 Tomcat 配置文档定义上下文:

可以显式定义单个 Context 元素:

Individual Context elements may be explicitly defined:

  • 在应用程序文件内/META-INF/context.xml 的单个文件中.可选(基于主机的 copyXML属性)这可以复制到$CATALINA_BASE/conf/[enginename]/[hostname]/并重命名为
    应用程序的基本文件名加上.xml"扩展名.
  • ...

另请注意:

如果要使用上下文路径部署 WAR 文件或目录与基本文件名无关,然后是以下之一必须使用选项来防止双重部署:

If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:

  • 禁用 autoDeploy 和 deployOnStartup 并在 server.xml 中定义所有上下文
  • 在主机的 appBase 之外找到 WAR 和/或目录,并使用具有 docBase 属性的 context.xml 文件来定义它.

这也符合您正在寻找的内容如何在 Tomcat 7.0 中设置 Web 应用程序的上下文路径

Also this is along the lines of what you are looking for How to set the context path of a web application in Tomcat 7.0

对于undertow,如果它在wildfly AS中用作Web服务器,请尝试使用jboss-web.xml,例如:https://stackoverflow.com/a/28475123/4807777

For undertow, if it's used as a web server in the wildfly AS try it with a jboss-web.xml like: https://stackoverflow.com/a/28475123/4807777

这篇关于Undertow 和 Tomcat 的 Spring Boot .war 上下文路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆