将spring boot应用程序部署到heroku-错误消息“没有正在运行的Web进程”

问题描述 投票:0回答:2

我创建了一个Spring Boot Web应用程序(在IntelliJ IDEA中,该应用程序在本地运行没有问题。

我尝试按照heroku在本演练中描述的步骤完全将应用程序部署到heroku:https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku

注意:本演练没有提到Procfile,所以我没有创建一个。

[在浏览器中打开应用程序的地址时,我遇到了“应用程序错误”。

日志显示构建应用程序已成功,但是显然有“没有Web进程正在运行”:

2020-02-06T20:42:19.262364 + 00:00 app [api]:用户创建的v1版本[email protected] 2020-02-06T20:42:19.598724 + 00:00 app [api]:用户[email protected]创建的版本v22020-02-06T20:42:19.262364 + 00:00 app [api]:用户最初发布[email protected] 2020-02-06T20:42:19.598724 + 00:00 app [api]:通过用户[email protected]启用Logplex2020-02-06T20:46:11.000000 + 00:00 app [api]:由用户启动的构建[email protected] 2020-02-06T20:46:56.626428 + 00:00 app [api]:用户[email protected]创建的版本v32020-02-06T20:46:56.626428 + 00:00 app [api]:按用户部署[email protected] 2020-02-06T20:47:04.000000 + 00:00 app [api]:构建成功2020-02-06T20:48:22.485742 + 00:00 heroku [router]:at =错误代码= H14 desc =“没有正在运行的Web进程” method = GET path =“ /”host = my-app.herokuapp.comrequest_id = 22e30a92-5094-4f8b-a51c-3f21177b19dc fwd =“ 95.88.203.176”dyno = connect = service = status = 503字节= protocol = https

我该如何解决?我必须做些什么?

java spring-boot heroku
2个回答
1
投票

似乎您正在尝试部署WAR文件。没有Web服务器,您将无法运行WAR文件。您有两个选择:

  1. Spring Boot可以将您的应用程序与嵌入式Web服务器捆绑在一起。这将完全避免该问题。
  2. 使用webapp-runner,它将为您运行WAR文件。 Heroku的Maven plugin可以帮助您进行设置。

我建议第一种方法。 Heroku在设置Spring引导应用程序时使用a great walkthrough


0
投票

假设您正在使用JAR,默认情况下将创建Procfile。您确定您的Web dyno仍在运行吗?如果您使用的是cli,则可以使用heroku ps查看其状态。如果显示没有测功力,则可以使用heroku ps:scale web=1扩大规模,然后尝试heroku open启动应用。

如果使用WAR,则可以遵循https://devcenter.heroku.com/articles/war-deployment,是的,您需要Procfile。

此外,在独立的tomcat上运行spring boot应用程序时,请不要忘记按照此处的步骤[C0

这里是我进行Spring Boot Heroku集成时拍摄的一些屏幕截图。

ProcFilehttps://docs.spring.io/spring-boot/docs/2.1.10.RELEASE/reference/html/howto-traditional-deployment.html

Pom(带有WebRunner插件)enter image description here演示应用程序(注意使用SpringBootServletInitializer)。如果不使用它,您将得到404。

enter image description here

首页enter image description here

Heroku日志

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.