Heroku Spring Boot Gradle App 已部署但 App 崩溃

Posted

技术标签:

【中文标题】Heroku Spring Boot Gradle App 已部署但 App 崩溃【英文标题】:Heroku Spring Boot Gradle App Deployed but App is crashing 【发布时间】:2021-12-21 23:18:29 【问题描述】:

我已经使用 PostgreSQL 数据库创建了 Spring Boot Gradle 应用程序并部署在 heroku 上

remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/gradle
remote: -----> Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing JDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x check
remote:        To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
remote:        Daemon will be stopped at the end of the build
remote:        > Task :compileJava
remote:        > Task :processResources
remote:        > Task :classes
remote:        > Task :bootJarMainClassName
remote:        > Task :bootJar
remote:        > Task :jar
remote:        > Task :assemble
remote:        > Task :build
remote:
remote:        BUILD SUCCESSFUL in 10s
remote:        5 actionable tasks: 5 executed
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote:        Done: 88.2M
remote: -----> Launching...
remote:        Released v31
remote:        https://lawcase.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/lawcase.git
   464da17..2c2db7c  main -> main

应用程序部署在 heroku 上,此 URL https://lawcase.herokuapp.com,我在我的 Spring Boot 应用程序中开发了 Rest API, 我还添加了 ProcFile

web: java -jar build/libs/LawCase-0.0.1-SNAPSHOT-plain.jar

但是当我尝试使用带有 Postman 的 URL 访问 API 时

 https://lawcase.herokuapp.com/getprofiles

我收到 503 服务不可用

这里是heroku日志

    2021-11-09T08:13:26.000000+00:00 app[api]: Build started by user ahmad.sardar@hotmail.com
2021-11-09T08:13:53.069450+00:00 app[api]: Release v30 created by user ahmad.sardar@hotmail.com
2021-11-09T08:13:53.069450+00:00 app[api]: Deploy 464da17a by user ahmad.sardar@hotmail.com
2021-11-09T08:13:56.790716+00:00 heroku[web.1]: State changed from crashed to starting
2021-11-09T08:13:59.975307+00:00 heroku[web.1]: Starting process with command `java -jar build/libs/LawCase-0.0.1-SNAPSHOT-plain.jar`
2021-11-09T08:14:00.808404+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
2021-11-09T08:14:00.883195+00:00 app[web.1]: no main manifest attribute, in build/libs/LawCase-0.0.1-SNAPSHOT-plain.jar
2021-11-09T08:14:01.026544+00:00 heroku[web.1]: Process exited with status 1
2021-11-09T08:14:01.157284+00:00 heroku[web.1]: State changed from starting to crashed
2021-11-09T08:14:01.179061+00:00 heroku[web.1]: State changed from crashed to starting
2021-11-09T08:14:04.663230+00:00 heroku[web.1]: Starting process with command `java -jar build/libs/LawCase-0.0.1-SNAPSHOT-plain.jar`
2021-11-09T08:14:05.581810+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
2021-11-09T08:14:05.645857+00:00 app[web.1]: no main manifest attribute, in build/libs/LawCase-0.0.1-SNAPSHOT-plain.jar
2021-11-09T08:14:05.769007+00:00 heroku[web.1]: Process exited with status 1
2021-11-09T08:14:06.249030+00:00 heroku[web.1]: State changed from starting to crashed
2021-11-09T08:14:07.000000+00:00 app[api]: Build succeeded
2021-11-09T08:14:45.278393+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lawcase.herokuapp.com request_id=788e94d4-a03c-4df8-a9aa-d1b68cc69c55 fwd="39.45.237.31" dyno= connect= service= status=503 bytes= protocol=https
2021-11-09T08:14:46.771103+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lawcase.herokuapp.com request_id=35c2d34e-95f2-473c-96f5-b25306390781 fwd="39.45.237.31" dyno= connect= service= status=503 bytes= protocol=https
2021-11-09T08:15:09.157754+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/getprofiles" host=lawcase.herokuapp.com request_id=dfc5e5f1-1ab8-4dd4-9677-c6557e5dae38 fwd="39.45.237.31" dyno= connect= service= status=503 bytes= protocol=https

我尝试过***的不同解决方案

Heroku jar deployment of Spring Boot with Maven Application giving code=H10

Heroku error code H10 when Spring Boot app is deployed

Spring Boot on Heroku - H10 "app crash"

How can resolve 503 (Service Unavailable) after GET/POST on Spring Boot and Heroku?

heroku[web.1]: State changed from starting to crashed

但是我无法解决我的问题并且我的应用程序无法运行,谁能帮助我在 Heroku 上正确部署和升级我的应用程序。

【问题讨论】:

【参考方案1】:

回答是因为我无法发表评论。几个想法。 Spring Boot 应用程序可能不需要 Procfile,因为有一个内置的 Web 服务器(除非你想覆盖某些东西)。还发现了 this 类似的情况,这是一个 postgres 驱动程序问题。

【讨论】:

以上是关于Heroku Spring Boot Gradle App 已部署但 App 崩溃的主要内容,如果未能解决你的问题,请参考以下文章

Heroku Spring Boot Gradle App 已部署但 App 崩溃

使用 bitbucket 管道部署到 heroku 的 Spring Boot gradle 项目在 build/libs/app-SNAPSHOT-plain.jar 中给出错误 no main m

Spring Boot + Kotlin + Gradle - 错误:在类中找不到主要方法

Heroku H14(没有运行 Web 进程)+ Spring-boot

Heroku Spring Boot 不构建 Jar

Spring Boot + Angular 2 Heroku 部署