[英]server.port and server.context-path not taking effect when deployed to tomcat
I have a springboot application which i want to deploy in tomcat . 我有一个springboot应用程序,我想在tomcat中进行部署。 i followed the instructions here I have application.properties file in src/main/resources with following entries 我按照这里的说明进行操作,我在src / main / resources中有application.properties文件,其中包含以下条目
server.context-path=/mycontext
server.port=9000
I can see that those properties are loaded from actuator urls. 我可以看到这些属性是从执行器URL加载的。
applicationConfig: [classpath:application.properties]": {
"server.port": "9000",
"server.context-path": "/mycontext"}
it works fine when i run it as an executable jar but when i deploy to tomcat it still listens to 8080 port and context value is not updated instead it falls back to application folder name. 当我将其作为可执行jar运行时,它工作正常,但是当我部署到tomcat时,它仍然侦听8080端口,并且上下文值未更新,而是回退到应用程序文件夹名称。 Please let me know if i have missed something . 请让我知道我是否错过了什么。 Thanks in advance. 提前致谢。
By default, 默认,
Tomcat listens in port 8080 and when you have deployed the war in tomcat it also listen on port 8080, this can't change the listening port of tomcat. Tomcat侦听端口8080,当您将战争部署在tomcat中时,它也会侦听端口8080,这无法更改tomcat的侦听端口。
The application.properties
file is the configuration of your springboot project but it is not for the tomcat. application.properties
文件是您的springboot项目的配置,但不适用于tomcat。
There is a builtin tomcat in springboot project. springboot项目中有一个内置的tomcat。 When you change its configuration in application.properties
file, it will change the configuration of builtin tomcat automatically. 在application.properties
文件中更改其配置时,它将自动更改内置tomcat的配置。
If you want to deploy your project to tomcat and listen on port 9000 then you need to change the configuration file of your tomcat (Changing listening port from 8080
to 9000
). 如果要将项目部署到tomcat并侦听端口9000,则需要更改tomcat的配置文件(将侦听端口从8080
更改为9000
)。
NB : Springboot project provides us with smart deploying technique with just a command. 注意 :Springboot项目仅通过一条命令即可为我们提供智能部署技术。 If you use springboot project then it is unnecessary to use another tomcat for deployment. 如果您使用springboot项目,则无需使用其他tomcat进行部署。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.