[英]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.