java - 简单的 Web Java 应用程序可与 heroku 本地 Web 配合使用,但部署时会崩溃

标签 java web heroku deployment

我在我的 web java 应用程序中使用 maven 3 和 JDK8。当我用 heroku 本地网络运行它时,它工作得很好。应用程序的部署也工作正常,但是当我尝试访问任何路由时,我收到此错误消息:

2019-11-16T16:18:12.213730+00:00 heroku[web.1]: State changed from crashed to starting
2019-11-16T16:18:14.828031+00:00 heroku[web.1]: Starting process with command `java -Dserver.port=5000 -cp target/classes:target/dependency/* Server`
2019-11-16T16:18:16.737715+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2019-11-16T16:18:16.741192+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2019-11-16T16:18:16.852336+00:00 app[web.1]: Servidor à espera de ligações no porto 5000
2019-11-16T16:19:45.407156+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-16T16:19:45.285183+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2019-11-16T16:19:45.285183+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-11-16T16:19:45.382598+00:00 heroku[web.1]: Process exited with status 137
2019-11-16T16:22:20.485432+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sd-back-end.herokuapp.com request_id=6b2ff817-990a-4b10-bd4d-fb2a929ea1fc fwd="149.90.124.74" dyno= connect= service= status=503 bytes= protocol=https
2019-11-16T16:22:20.951050+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sd-back-end.herokuapp.com request_id=894ab47b-a10d-4467-84b3-7ed824b6ff7c fwd="149.90.124.74" dyno= connect= service= status=503 bytes= protocol=https

过程文件:

web: java -Dserver.port=5000 -cp target/classes;target/dependency/* Server

此应用程序的代码:https://github.com/EDUnter/SD_Server

最佳答案

-Dserver.port=5000 替换为 -Dserver.port=$PORT

有关更多信息,请参阅Setting the HTTP Port for Java Applications

关于java - 简单的 Web Java 应用程序可与 heroku 本地 Web 配合使用,但部署时会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58892799/

相关文章:

java - Android工作室: How do I update a textview in a recyclerview when an item from the database is deleted?

java - 从 List<Map<K,V>> 到 List<V> 的转换(从 map 列表中获取所有唯一值)

java - 无法在 ContainerRequestFilter 中接收 header 参数

java - 在 CDI(焊接)中注入(inject)对象列表

javascript - 奇怪的 heroku 命令错误

html - 页脚不在底部

javascript - VB.NET Gecko Web 浏览器 javascript 函数调用?

php - 获取表格内列中显示的数据总数

node.js - 有没有办法将我的控制台附加到 heroku 应用程序以查看应用程序/网站事件?

java - 在 Heroku 上部署 war 所需的步骤