简体   繁体   English

在容器tomcat服务器上更改已部署(Spring Boot)战争的上下文路径。 所以它不是demo-0.01-SNAPSHOT

[英]Changing the context path of deployed (Spring Boot) war on a container tomcat server. So it is not demo-0.01-SNAPSHOT

I have tried to deploy my site using many configurations to make it change from the war name being deployed. 我尝试使用许多配置部署我的站点,以使其从正在部署的战争名称进行更改。 Is there a way to do this easily. 有没有办法轻松做到这一点。 The deployment will to a tomcat sitting somewhere else. 部署将在一个tomcat坐在其他地方。 eg bitnami instance 例如bitnami实例

I have tried various combinations of settings in the application.properties but none make any difference: 我在application.properties中尝试了各种设置组合,但没有任何区别:

 server.servlet.context-path=/a
    server.servlet.path=/b
    spring.webservices.path=/c
    server.contextPath=/m

The war is called demo-0.0.01-SNAPSHOT.war and when dropped in the webapps directory it creates the same named directory and the site then has a /demo-0.0.01-SNAPSHOT path. 战争称为demo-0.0.01-SNAPSHOT.war,当放入webapps目录时,它会创建相同的命名目录,然后该站点有一个/demo-0.0.01-SNAPSHOT路径。 I thought with the days of Spring Boot this would be easy now but a fool like me hasn't worked it out yet. 我认为Spring Boot的日子现在很容易,但像我这样的傻瓜还没有解决。 Or do people just deploy embedded versions with tomcats and run them nowadays? 或者人们只是使用tomcats部署嵌入式版本并立即运行它们?

(BTW I have tried the root.xml as well, no luck ... unless i did it wrong on my windows box, testing on my dev box first, linux for deployment) (顺便说一句,我也尝试了root.xml,没有运气......除非我在我的Windows机箱上做错了,先在我的开发盒上进行测试,然后在linux上进行部署)

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

The Spring Boot property to specify the context path of the application is : server.contextPath . 用于指定应用程序的上下文路径的Spring Boot属性是: server.contextPath
But the fact that you are deploying your WAR into a standalone Tomcat instance doesn't allow to use it. 但是,将WAR部署到独立的Tomcat实例中的事实不允许使用它。
In this configuration, you cannot use server.contextPath and other properties specific to the container (as for example server.port ). 在此配置中,您不能使用server.contextPath和特定于容器的其他属性(例如server.port )。 These are designed to work with the embedded Tomcat instance. 这些设计用于嵌入式Tomcat实例。

The standalone Tomcat instance keeps indeed the control on these facilities provided by Spring Boot. 独立的Tomcat实例确实可以控制Spring Boot提供的这些工具。 So you have to configure it from the configuration file of the standalone Tomcat (server.xml or ROOT.xml way generally). 因此,您必须从独立Tomcat的配置文件(通常是server.xml或ROOT.xml方式)配置它。

Adding finalName setting to pom.xml for maven will make the packaged war filename to it. finalName设置添加到maven的pom.xml为其创建打包的war文件名。 For example. 例如。

<build>
...
<finalName>myapp</finalName>
</build>

The packaged filename will be myapp.war . 打包的文件名将是myapp.war When you deploy to tomcat it will set the context to the filename. 部署到tomcat时,它会将上下文设置为文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Undertow和Tomcat的Spring Boot .war上下文路径 - Spring Boot .war context path for Undertow and Tomcat Spring boot WAR 部署到 Tomcat 并且缺少静态资源的上下文 - Spring boot WAR deployed to Tomcat and missing context for static resources Spring 启动 - 自动生成上下文。xml 将战争文件部署到 tomcat - Spring Boot - Autogenerate context.xml while war file is deployed to tomcat Spring Boot / Gradle / Tomcat将上下文路径设置为除.war名称之外的其他内容 - Spring Boot/Gradle/Tomcat setting context path to something other than the .war name 如何在Spring Boot应用程序中启用HTTPS,该应用程序在Tomcat中作为WAR文件部署? - How to enable HTTPS in a Spring Boot application, deployed as WAR file in Tomcat? Tomcat 战争已部署,但 spring 引导应用程序未开始运行 - Tomcat war gets deployed but spring boot app does not start running 在 Spring 中增加 class 加载计数 在 Tomcat 上部署为 WAR 的引导应用程序 - Increasing class loaded count in Spring Boot application deployed as WAR on Tomcat Spring 启动 REST 应用程序部署为 tomcat 上的 WAR 不工作 - Spring boot REST application deployed as WAR on tomcat is not working 当以传统方式部署时,Spring Boot尝试运行嵌入式Tomcat - Spring Boot tries to run an embedded Tomcat when deployed as traditional war Spring Boot 上下文路径被外部 Tomcat 忽略 - Spring Boot Context Path Ignored With External Tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM