Heroku - Java Maven 项目解聚 - 完成 git push heroku master 后出现应用程序错误
Posted
技术标签:
【中文标题】Heroku - Java Maven 项目解聚 - 完成 git push heroku master 后出现应用程序错误【英文标题】:Heroku - Java Maven project depoly - getting application error after complete git push heroku master 【发布时间】:2019-03-08 16:50:37 【问题描述】:我使用 Maven 制作了一个简单的 Java Web 应用程序,我正在尝试部署它。起初,我有一个错误:
error: src refspec master does not match any.
error: failed to push some refs to 'git@heroku.com: etc ...'
但是,我在这里找到了解决方案: I want make push and get error: src refspec master does not match any
一段时间后,我在终端中收到以下信息:
remote: [INFO] BUILD SUCCESS
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 11.039 s
remote: [INFO] Finished at: 2018-10-03T12:25:10+00:00
remote: [INFO] Final Memory: 24M/172M
remote: [INFO] ------------------------------------------------------------------------
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote:
remote: -----> Compressing...
remote: Done: 63.5M
remote: -----> Launching...
remote: Released v3
remote: https://immense-falls-73440.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
但是当我尝试 heroku open 或者只是去 URL 时,只有信息:应用程序错误。
这是我的heroku日志:
2018-10-02T20:55:00.135902+00:00 app[api]: Release v1 created by user mymail@mail.com
2018-10-02T20:55:00.225698+00:00 app[api]: Enable Logplex by user mymail@mail.com
2018-10-02T20:55:00.225698+00:00 app[api]: Release v2 created by user mymail@mail.com
2018-10-02T20:55:00.135902+00:00 app[api]: Initial release by user mymail@mail.com
2018-10-02T20:56:51.945196+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=97651816-2e92-4196-add2-4cdd5325ca30 fwd="87.206.210.121"
dyno= connect= service= status=502 bytes= protocol=https
2018-10-02T20:56:52.583382+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=ca3e65a7-6ef1-4253-a946-2d0cc2e99dc1 fwd="87.20
6.210.121" dyno= connect= service= status=502 bytes= protocol=https
2018-10-02T20:56:52.583849+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=9ae591af-d87c-4224-9832-dff44ea68fd1 fwd="87.20
6.210.121" dyno= connect= service= status=502 bytes= protocol=https
2018-10-03T12:24:54.000000+00:00 app[api]: Build started by user mymail@mail.com
2018-10-03T12:25:18.147522+00:00 app[api]: Release v3 created by user mymail@mail.com
2018-10-03T12:25:18.147522+00:00 app[api]: Deploy 6d354e57 by user mymail@mail.com
2018-10-03T12:25:20.000000+00:00 app[api]: Build succeeded
2018-10-03T12:26:45.829110+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=8ebfefdc-d2a9-438d-a224-11f39ec21781 fwd="
87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T12:26:46.544850+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=2af704d0-9703-4fe6-a173-2691ca0
fdd39 fwd="87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T12:26:46.538716+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=11cd4e6d-f850-4687-bc6a-863f30e
667f8 fwd="87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
这是我第一次将任何 Java 项目部署到网络上,我感到很困惑,我真的不明白哪里出了问题以及如何解决它。
添加Procfile后:java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
我又遇到了错误,这是我的日志:
2018-10-02T20:55:00.135902+00:00 app[api]: Release v1 created by user mymail@gmail.com
2018-10-02T20:55:00.225698+00:00 app[api]: Enable Logplex by user mymail@gmail.com
2018-10-02T20:55:00.225698+00:00 app[api]: Release v2 created by user mymail@gmail.com
2018-10-02T20:55:00.135902+00:00 app[api]: Initial release by user mymail@gmail.com
2018-10-02T20:56:51.945196+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=97651816-2e92-4196-add2-4cdd5325ca30 fwd="87.206.210.121"
dyno= connect= service= status=502 bytes= protocol=https
2018-10-02T20:56:52.583382+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=ca3e65a7-6ef1-4253-a946-2d0cc2e99dc1 fwd="87.20
6.210.121" dyno= connect= service= status=502 bytes= protocol=https
2018-10-02T20:56:52.583849+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=9ae591af-d87c-4224-9832-dff44ea68fd1 fwd="87.20
6.210.121" dyno= connect= service= status=502 bytes= protocol=https
2018-10-03T12:24:54.000000+00:00 app[api]: Build started by user mymail@gmail.com
2018-10-03T12:25:18.147522+00:00 app[api]: Release v3 created by user mymail@gmail.com
2018-10-03T12:25:18.147522+00:00 app[api]: Deploy 6d354e57 by user mymail@gmail.com
2018-10-03T12:25:20.000000+00:00 app[api]: Build succeeded
2018-10-03T12:26:45.829110+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=8ebfefdc-d2a9-438d-a224-11f39ec21781 fwd="
87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T12:26:46.544850+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=2af704d0-9703-4fe6-a173-2691ca0
fdd39 fwd="87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T12:26:46.538716+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=11cd4e6d-f850-4687-bc6a-863f30e
667f8 fwd="87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T12:29:48.298049+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=4fe1f9d8-e616-4018-8f66-3496194563ee fwd="
87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T12:32:38.432481+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=1b50b089-1aa9-449e-b2f2-7d10182e4955 fwd="
87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T13:01:22.328331+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=83248761-74af-4fa4-b26b-f69a9d8da7b6 fwd="
156.114.128.11" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T13:01:23.283855+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=immense-falls-73440.herokuapp.com request_id=cdc081f2-193a-4490-8e79-7d2c6d8
725a3 fwd="156.114.128.11" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T13:22:47.102561+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=bc9ef838-d37d-4db5-9fb1-338bb5b4cdd2 fwd="
52.32.223.31" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T14:01:33.109607+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=bd761dab-f0fa-439f-9141-39581694d536 fwd="
156.114.160.11" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T20:09:40.000000+00:00 app[api]: Build started by user mymail@gmail.com
2018-10-03T20:09:57.925786+00:00 app[api]: Deploy 27d345c5 by user mymail@gmail.com
2018-10-03T20:09:57.925786+00:00 app[api]: Release v4 created by user mymail@gmail.com
2018-10-03T20:10:00.000000+00:00 app[api]: Build succeeded
2018-10-03T20:34:58.002908+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=immense-falls-73440.herokuapp.com request_id=4a875fae-4370-49e0-b1df-4c4ac578294b fwd="
87.206.210.121" dyno= connect= service= status=503 bytes= protocol=https
【问题讨论】:
【参考方案1】:在您的构建日志中显示:
remote: Procfile declares types -> (none)
这意味着 Heroku 不会启动任何进程,这就是您收到“没有运行 Web 进程”错误的原因。
你的Procfile
是什么样的?它可能是空的。你需要这样的东西:
web: java -jar target/myapp.jar
将java
命令替换为适当的java
命令以启动您的应用。
【讨论】:
您好!我肯定会尝试您的解决方案,并告知是否可行:) 我是根据以下指南进行操作的:devcenter.heroku.com/articles/procfile#developing-locally 并且有信息:部署到 Heroku A Procfile 不需要部署以大多数语言编写的应用程序赫罗库。平台会自动检测语言,并创建默认的 Web 进程类型来启动应用程序服务器。所以我什至没有将 Procfile 添加到我的项目中。 我在 Procfile 中添加了以下内容: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war 我在 Procfile 中添加了以下内容: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war 将其保存为 Procfile,在项目的主文件夹然后再次提交并推送,但是,我得到了扩展日志,我已将其添加到原始帖子中。 您在构建输出中看到Procfile declares types -> web
了吗?试试heroku ps:scale web=1
它返回给我:$ heroku ps:scale web=1 Scaling dynos...! !找不到该进程类型。所以我的 Procfile 还是错了?以上是关于Heroku - Java Maven 项目解聚 - 完成 git push heroku master 后出现应用程序错误的主要内容,如果未能解决你的问题,请参考以下文章
Heroku 无法部署 Java 11 Spring Boot App [重复]