简体   繁体   English

server.port和server.context-path部署到tomcat时不生效

[英]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进行部署。

server.* config values in application.properties only apply to embedded server. server。* application.properties中的配置值仅适用于嵌入式服务器。 External container by default uses the application name as the context root as mentioned here 默认情况下,外部容器使用应用程序的名称作为上下文根提到这里

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

相关问题 maven:无法覆盖 tomcat 服务器的 server.port - maven: can't override server.port for tomcat server Spring Boot + Tomcat 忽略 server.port 属性? - Spring Boot + Tomcat ignoring server.port property? 无法解析值“${server.port}”中的占位符“server.port” - Could not resolve placeholder 'server.port' in value "${server.port}" 将server.context-path设置为myApp的管理基本路径设置为“ /” - Set management base-path to “/” having server.context-path setted to myApp springboot 测试@value("${server.port}") - springboot test @value("${server.port}") 部署 Springboot Web 服务 Heroku。 配置 Dyno 形成时出现错误 [无法访问 jarfile server.port] - Deploy Springboot Webserivce Heroku. ERROR [Unable to access jarfile server.port] when config Dyno formation 在容器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 Spring Boot重命名application.properties中的server.port - Spring Boot renaming server.port in application.properties 构建 spring boot 项目后 server.port 属性不起作用 - server.port properties not working after buildin spring boot project 动态获取Apache Tomcat服务器路径和端口 - Getting Apache Tomcat server path and port dynamically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM