只是学习,所以提前感谢您的理解。
我构建了一些训练Java SpringBoot项目。这是一个简单的网络套接字聊天,但这没关系。它通过 Eclipse 或 Maven(没有 Eclipse(在本地成功运行。
现在我的任务是使用 Heroku 在 web 中运行它。我使用 GitHub 在 Heroku 中部署了它。应用程序通过heroku local
成功运行,但在网络中它会崩溃,我不知道为什么。我的程序文件:
web: java -jar target/testweb3-0.0.1-SNAPSHOT.war
Heroku 日志:
2020-05-13T17:58:33.479226+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-13T17:58:41.066644+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2020-05-13T17:58:41.071889+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-05-13T17:58:43.079324+00:00 app[web.1]:
2020-05-13T17:58:43.079416+00:00 app[web.1]: . ____ _ __ _ _
2020-05-13T17:58:43.079514+00:00 app[web.1]: /\ / ___'_ __ _ _(_)_ __ __ _
2020-05-13T17:58:43.079610+00:00 app[web.1]: ( ( )___ | '_ | '_| | '_ / _` |
2020-05-13T17:58:43.079706+00:00 app[web.1]: \/ ___)| |_)| | | | | || (_| | ) ) ) )
2020-05-13T17:58:43.079799+00:00 app[web.1]: ' |____| .__|_| |_|_| |___, | / / / /
2020-05-13T17:58:43.079919+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-05-13T17:58:43.081637+00:00 app[web.1]: :: Spring Boot :: (v2.2.3.RELEASE)
2020-05-13T17:58:43.081700+00:00 app[web.1]:
2020-05-13T17:58:43.470225+00:00 app[web.1]: 2020-05-13 17:58:43.463 INFO 4 --- [ main] testweb3.controller.Application : Starting Application v0.0.1-SNAPSHOT on 2822987a-4c88-4248-ae00-4b0832ebd7c2 with PID 4 (/app/target/testweb3-0.0.1-SNAPSHOT.war started by u59116 in /app)
2020-05-13T17:58:43.472319+00:00 app[web.1]: 2020-05-13 17:58:43.472 INFO 4 --- [ main] testweb3.controller.Application : No active profile set, falling back to default profiles: default
2020-05-13T17:58:46.129477+00:00 app[web.1]: 2020-05-13 17:58:46.129 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 0 (http)
2020-05-13T17:58:46.144819+00:00 app[web.1]: 2020-05-13 17:58:46.144 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-13T17:58:46.145182+00:00 app[web.1]: 2020-05-13 17:58:46.145 INFO 4 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-05-13T17:58:47.987053+00:00 app[web.1]: 2020-05-13 17:58:47.986 INFO 4 --- [ main] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2020-05-13T17:58:48.140150+00:00 app[web.1]: 2020-05-13 17:58:48.139 INFO 4 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-13T17:58:48.140335+00:00 app[web.1]: 2020-05-13 17:58:48.140 INFO 4 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4467 ms
2020-05-13T17:58:48.359123+00:00 app[web.1]: 2020-05-13 17:58:48.358 INFO 4 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientInboundChannelExecutor'
2020-05-13T17:58:48.364258+00:00 app[web.1]: 2020-05-13 17:58:48.364 INFO 4 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientOutboundChannelExecutor'
2020-05-13T17:58:48.372881+00:00 app[web.1]: 2020-05-13 17:58:48.372 INFO 4 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'messageBrokerTaskScheduler'
2020-05-13T17:58:48.456122+00:00 app[web.1]: 2020-05-13 17:58:48.455 INFO 4 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'brokerChannelExecutor'
2020-05-13T17:58:50.143529+00:00 app[web.1]: 2020-05-13 17:58:50.143 INFO 4 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Starting...
2020-05-13T17:58:50.143807+00:00 app[web.1]: 2020-05-13 17:58:50.143 INFO 4 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2020-05-13T17:58:50.145205+00:00 app[web.1]: 2020-05-13 17:58:50.145 INFO 4 --- [ main] o.s.m.s.b.SimpleBrokerMessageHandler : Started.
2020-05-13T17:58:50.209917+00:00 app[web.1]: 2020-05-13 17:58:50.209 INFO 4 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 33163 (http) with context path ''
2020-05-13T17:58:50.221351+00:00 app[web.1]: 2020-05-13 17:58:50.221 INFO 4 --- [ main] testweb3.controller.Application : Started Application in 8.005 seconds (JVM running for 9.15)
2020-05-13T17:59:48.454213+00:00 app[web.1]: 2020-05-13 17:59:48.453 INFO 4 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
2020-05-13T18:00:09.026314+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-13T18:18:54.299951+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=chat-vu.herokuapp.com request_id=5c30f183-f455-4760-a3b0-3c1b5d8835ae fwd="31.173.30.38" dyno= connect= service= status=503 bytes= protocol=https
2020-05-13T18:18:55.362479+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=chat-vu.herokuapp.com request_id=848e21a6-86f7-42b8-be18-01d79d96d6c0 fwd="31.173.30.38" dyno= connect= service= status=503 bytes= protocol=https
2020-05-13T18:18:58.408258+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=chat-vu.herokuapp.com request_id=ed6b1b54-5d8c-4b43-acb1-8314ad965a20 fwd="31.173.30.38" dyno= connect= service= status=503 bytes= protocol=http
2020-05-13T18:18:59.426224+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/login" host=chat-vu.herokuapp.com request_id=182cbc27-56c0-4961-9deb-9518e1ca86d2 fwd="31.173.30.38" dyno= connect= service= status=503 bytes= protocol=https
2020-05-13T18:19:00.070337+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=chat-vu.herokuapp.com request_id=7c9c4519-3ec2-42bd-a83b-f6eb3c1ea8f2 fwd="31.173.30.38" dyno= connect= service= status=503 bytes= protocol=https
GitHub上的项目在这里。
请帮忙:)
您没有在 Heroku 通过$PORT
环境变量给出的端口上运行您的应用程序。将Procfile
内容更改为:
web: java -Dserver.port=$PORT -jar target/testweb3-0.0.1-SNAPSHOT.war
以解决您的问题。您可以在此处阅读有关该主题的更多信息:https://devcenter.heroku.com/articles/setting-the-http-port-for-java-applications#spring-boot