【问题标题】:How to start two spring boot apps如何启动两个 Spring Boot 应用程序
【发布时间】:2014-05-30 07:23:34
【问题描述】:

我正在玩弹簧靴。所以我想创建两个相互交互的微服务。我的问题是我无法同时启动它们,因为当第一个应用程序已经使用自己的 tomcat 运行时,第二个应用程序无法启动:

Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat

我该如何解决这个问题?

谢谢!

【问题讨论】:

    标签: spring tomcat spring-boot


    【解决方案1】:

    您需要更改第二个应用程序使用的端口(以避免同一 TCP 端口的冲突)。 一种方法是添加类似

    的属性
    server.port = 8090
    

    到第二个应用程序的application.properties

    【讨论】:

      【解决方案2】:

      另一种选择是将端口指定为命令行开关。这使得在运行时操作事情变得更容易,无需恢复到可能对您最终部署到的环境有效或可能无效的属性设置。

      java -Dserver.port=8081 -jar target/springboot-0.0.1-SNAPSHOT.jar
      

      【讨论】:

      • 我更喜欢这个。从操作的角度来看,这使得 JAR 更易于管理。
      猜你喜欢
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      • 2022-11-11
      • 2015-05-10
      相关资源
      最近更新 更多