java - 在外部 tomcat 上运行 war 文件时禁止将 appName 添加到 url

标签 java tomcat tomcat7 spring-boot

<分区>

我遵循了官方 spring 教程“使用 Maven 将 Spring Boot JAR 应用程序转换为 WAR”link .

生成的 war 文件部署在 tomcat 上,可在以下位置访问:

a)http://localhost:8080/${AppName}/
http://localhost:8080/gs-convert-jar-to-war-maven-0.1.0/  in case of the tutorial.

我需要更改哪些配置才能使我的应用程序直接在

http://localhost:8080/  (without the appName) 

在 tomcat 上运行我的 war 文件时?

谢谢,

罗恩

最佳答案

您必须更改应用程序的 contextRoot。 您可以在 3 个地方执行此操作:

  • 在WAR中的一个文件中:META-INF/context.xml
  • 在 TOMCAT_HOME/conf/Catalina/localhost/xxx.xml 中
  • 或在 server.xml 文件中,但最好不要在此处更改。

在其中一个地方,您可以添加:

<Context
        path="/"
        docBase="/TOMCAT_HOME/webapps/yourapp"
    />

关于java - 在外部 tomcat 上运行 war 文件时禁止将 appName 添加到 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23883976/

相关文章:

java - 图像上传 Servlet 在 Chrome 中不工作,但在其他浏览器中工作

java - 如何使用OpenCV和Java来挽回面子和识别?

Tomcat 将多个基本端口作为环境变量传递

java - slf4j 升级绑定(bind)更新错误?不兼容的绑定(bind)

tomcat - 带有外部配置文件的grails war tomcat

java - 有效地找到排序数组中的整数数量

java - Jackson 将类名序列化为所有对象的属性

tomcat - 将 WAR 部署到正确的 WebApps 文件夹

apache - 使用 Apache 2.2 和 Tomcat 6 的 Web 应用程序的虚拟主机或代理

java - 无法检测 Spring AOP 中的类级别自定义注释