【问题标题】:Changing the port of Spring boot application through application.properties when deployed it on an external tomcat server将 Spring Boot 应用程序部署到外部 tomcat 服务器时,通过 application.properties 更改其端口
【发布时间】:2019-08-15 14:00:56
【问题描述】:

我已经在外部 tomcat 服务器上部署了一个 spring boot 应用程序。 server.xml 中配置的端口为 9090 ,而 application.properties 文件中的 server.port 为 8080 。并且应用程序部署在 9090 上。有什么方法可以在 application.properties 文件中配置的端口(即 8080)上启动/部署我的应用程序?

【问题讨论】:

  • server.* 属性仅适用于使用嵌入式容器而不是部署到外部服务器时。唯一的方法是使用额外的连接器配置 tomcat 并将您的应用程序绑定到该连接器,但您都必须在外部 tomcat 中配置它。
  • @M.Deinum 感谢您的回复。能否请您告诉我如何在外部 tomcat 中进行该配置?

标签: spring-boot tomcat9


【解决方案1】:

我的想法是,application.propertiesserver.port 属性的值是指嵌入式服务器的端口而不是外部服务器。

如果您总是需要在application.properties 中提到的端口上部署您的项目,那么您需要使用嵌入式服务器。

通过添加嵌入式服务器对pom.xml的依赖即可实现。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

然后运行你的 Spring boot 邮件类或通过命令行运行你的 jar。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-27
    • 1970-01-01
    • 2019-06-15
    • 2018-11-30
    • 2015-08-22
    • 2016-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多