首页 > 解决方案 > 开发环境中springboot应用程序war文件的上下文根

问题描述

我使用 maven 在 application.properties 中使用以下配置构建了一个 Spring Boot War 文件(WebApplication)。server.servlet.context-path=/app 在开发环境中手动部署Tomcat中的war时,不是读取上下文路径,而是使用war文件的名称作为上下文路径。

战争文件名:AgentApp.0.0.1.SNAPSHOT。

实际网址:http ://dev.com/AgentApp.0.0.1.SNAPSHOT/index.html 。

预期网址:http ://dev.com/app/index.html 。

PS:当从 Eclipse 运行时,这在我的本地环境中运行良好。(不使用嵌入式 tomcat)。

标签: springspring-boottomcat8

解决方案


我们可以<finalName> 在 pom.xml 中添加标签。当 maven 构建完成时,war/jar 文件将是 finalName 的名称。


推荐阅读