You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot WAR部署到Heroku后出现HTTP Status 404问题求助

Spring Boot WAR包部署到Heroku后出现404错误

通过mvn clean heroku:deploy-war命令将Java Spring Boot应用打包成WAR包部署到Heroku,部署流程显示成功,但执行heroku open打开应用URL时,页面返回HTTP Status 404 – Not Found。Heroku实时日志(执行heroku logs --tail获取)内容如下:

2023-05-25T20:37:05.000000+00:00 app[api]: Build started by user me@gmail.com
2023-05-25T20:37:16.000000+00:00 app[api]: Build succeeded
2023-05-25T20:37:16.577638+00:00 app[api]: Deploy 0.0.1-SNAPSHOT by user me@gmail.com
2023-05-25T20:37:16.577638+00:00 app[api]: Release v9 created by user ,me@gmail.com
2023-05-25T20:37:17.538960+00:00 heroku[web.1]: Restarting
2023-05-25T20:37:17.551724+00:00 heroku[web.1]: State changed from up to starting
2023-05-25T20:37:18.166432+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2023-05-25T20:37:18.635556+00:00 heroku[web.1]: Process exited with status 143
2023-05-25T20:37:20.997881+00:00 heroku[web.1]: Starting process with command `java $JAVA_OPTS -jar webapp-runner.jar $WEBAPP_RUNNER_OPTS --port 43945 target/heroku-demo-0.0.1-SNAPSHOT.war`
2023-05-25T20:37:21.613131+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2023-05-25T20:37:21.616410+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2023-05-25T20:37:21.830115+00:00 app[web.1]: Expanding heroku-demo-0.0.1-SNAPSHOT.war into /app/target/tomcat.43945/webapps/expanded
2023-05-25T20:37:21.830135+00:00 app[web.1]: Adding Context  for /app/target/tomcat.43945/webapps/expanded
2023-05-25T20:37:22.028882+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.coyote.AbstractProtocol init
2023-05-25T20:37:22.028891+00:00 app[web.1]: INFO: Initializing ProtocolHandler ["http-nio-43945"]
2023-05-25T20:37:22.041652+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.catalina.core.StandardService startInternal
2023-05-25T20:37:22.041655+00:00 app[web.1]: INFO: Starting service [Tomcat]
2023-05-25T20:37:22.042036+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.catalina.core.StandardEngine startInternal
2023-05-25T20:37:22.042037+00:00 app[web.1]: INFO: Starting Servlet engine: [Apache Tomcat/9.0.30]
2023-05-25T20:37:22.123464+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
2023-05-25T20:37:22.123465+00:00 app[web.1]: INFO: No global web.xml found
2023-05-25T20:37:22.133227+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.tomcat.util.descriptor.web.WebXml setVersion
2023-05-25T20:37:22.133228+00:00 app[web.1]: WARNING: Unknown version string [5.0]. Default version will be used.
2023-05-25T20:37:22.134673+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.tomcat.util.descriptor.web.WebXml setVersion
2023-05-25T20:37:22.134673+00:00 app[web.1]: WARNING: Unknown version string [6.0]. Default version will be used.
2023-05-25T20:37:22.138126+00:00 app[web.1]: May 25, 2023 8:37:22 PM org.apache.tomcat.util.descriptor.web.WebXml setVersion
2023-05-25T20:37:22.138126+00:00 app[web.1]: WARNING: Unknown version string [6.0]. Default version will be used.
2023-05-25T20:37:22.182284+00:00 heroku[web.1]: State changed from starting to up
2023-05-25T20:37:23.848365+00:00 app[web.1]: May 25, 2023 8:37:23 PM org.apache.jasper.servlet.TldScanner scanJars
2023-05-25T20:37:23.848390+00:00 app[web.1]: INFO: 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.
2023-05-25T20:37:23.879011+00:00 app[web.1]: May 25, 2023 8:37:23 PM org.apache.coyote.AbstractProtocol start
2023-05-25T20:37:23.879012+00:00 app[web.1]: INFO: Starting ProtocolHandler ["http-nio-43945"]
2023-05-25T20:37:27.746466+00:00 heroku[router]: at=info method=GET path="/" host=my-hosted-app.herokuapp.com request_id=xxx fwd="my.ip" dyno=web.1 connect=0ms service=21ms status=404 bytes=864 protocol=https

应用访问根路径本该返回Hello World!,现在却返回404错误。尝试在URL后添加日志中显示的端口43945也无法解决问题。

404错误页面

内容的提问来源于stack exchange,提问作者BullyWiiPlaza

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 22:45:01