在Heroku上部署Spring Boot App-构建成功,但是:无法提供页面

时间:2020-05-16 13:37:28

标签: java spring spring-boot maven heroku

当我在IntelliJ或使用$ java -jar demo-0.0.1-SNAPSHOT.jar在cli中启动spring boot应用程序/服务器时,它在本地工作,并且heroku构建也成功,但是当我转到url时,它显示Application Error 。关于heroku为什么不显示我的网站的任何想法?

我已经做了在其他stackoverflow问题(Heroku cannot deploy Java 11 Spring Boot App)中发现的提示:
1.我确保Java版本相同:

my java version

my system.properties

在我的pom.xml文件中:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org  
/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-
4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
        <parent>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-parent</artifactId>
             <version>2.3.0.RELEASE</version>
             <relativePath/> <!-- lookup parent from repository -->
        </parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>11</java.version> <!-- =HERE is version 11 -->
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>

        </plugin>

    </plugins>
</build>

</project>
  1. 我在根目录中创建了一个包含以下内容的Procfile:

    网络:java -jar target / demo-0.0.1-SNAPSHOT.jar

  2. 我检查了SDK是否设置为11:

Java SDK in IntelliJ

  1. 我检查了Java编译器是否设置为11:

Java Compiler

另外,这是我的Maven版本:

my maven version

这些是我的路径系统变量:

path variables

所有这些实际上也都在我的git枢纽上:https://github.com/gkromer/test2 这是来自heroku的我的应用程序的链接:https://nameless-chamber-03761.herokuapp.com/

我还通过heroku入门页面上的简单演示对其进行了测试。效果很好,没问题。因此,我认为问题出在我的IntelliJ或Maven中,因为对于来自heroku的示例,我并不需要它(示例中的所有操作都可以使用CLI来完成)。 信息:我的春季应用程序中没有数据库。

我跑步时:

这是我的heroku日志尾巴:

$ heroku logs --tail
``2020-05-16T01:25:00.761021+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-05-16T01:25:00.761097+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-05-16T01:25:00.761171+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-05-16T01:25:00.761271+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-05-16T01:25:00.762564+00:00 app[web.1]: :: Spring Boot ::        (v2.3.0.RELEASE)
2020-05-16T01:25:00.762662+00:00 app[web.1]:
2020-05-16T01:25:01.061558+00:00 app[web.1]: 2020-05-16 01:25:01.058  INFO 4 --- [               
main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on 
0e5ba3e8-29ec-44ea-b140-f4c7d9fbefe9 with PID 4 (/app/target/demo-0.0.1-SNAPSHOT.jar started 
by u23518 in /app)
2020-05-16T01:25:01.062689+00:00 app[web.1]: 2020-05-16 01:25:01.062  INFO 4 --- [           
main] com.example.demo.DemoApplication         : No active profile set, falling back to 
default profiles: default
2020-05-16T01:25:02.824876+00:00 app[web.1]: 2020-05-16 01:25:02.824  INFO 4 --- [            
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-05-16T01:25:02.847429+00:00 app[web.1]: 2020-05-16 01:25:02.847  INFO 4 --- [           
main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-16T01:25:02.847833+00:00 app[web.1]: 2020-05-16 01:25:02.847  INFO 4 --- [            
main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache 
Tomcat/9.0.35]
2020-05-16T01:25:02.940699+00:00 app[web.1]: 2020-05-16 01:25:02.940  INFO 4 --- [           
main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded 
WebApplicationContext
2020-05-16T01:25:02.940837+00:00 app[web.1]: 2020-05-16 01:25:02.940  INFO 4 --- [           
main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization 
completed in 1789 ms
2020-05-16T01:25:03.219257+00:00 app[web.1]: 2020-05-16 01:25:03.218  INFO 4 --- [           
main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService  
'applicationTaskExecutor'
2020-05-16T01:25:03.409097+00:00 app[web.1]: 2020-05-16 01:25:03.408  INFO 4 --- [           
main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: ServletContext resource 
[/index.html]
2020-05-16T01:25:03.579270+00:00 app[web.1]: 2020-05-16 01:25:03.578  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with 
context path ''
2020-05-16T01:25:03.611887+00:00 app[web.1]: 2020-05-16 01:25:03.611  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Started DemoApplication in 3.485 seconds 
(JVM running for 4.243)
2020-05-16T01:26:27.841081+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-16T07:01:26.964378+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-16T07:01:32.866428+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno 
size. Custom settings will override them.
2020-05-16T07:01:32.872188+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: 
-XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-05-16T07:01:34.924230+00:00 app[web.1]:
2020-05-16T07:01:34.924383+00:00 app[web.1]: .   ____          _            __ _ _
2020-05-16T07:01:34.924501+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2020-05-16T07:01:34.924566+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-05-16T07:01:34.924676+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-05-16T07:01:34.924759+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-05-16T07:01:34.924858+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-05-16T07:01:34.926470+00:00 app[web.1]: :: Spring Boot ::        (v2.3.0.RELEASE)
2020-05-16T07:01:34.926515+00:00 app[web.1]:
2020-05-16T07:01:35.320062+00:00 app[web.1]: 2020-05-16 07:01:35.315  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on 
00e45ce7-7952-453c-a8f1-ed845e4c193e with PID 4 (/app/target/demo-0.0.1-SNAPSHOT.jar started 
by u31109 in /app)
2020-05-16T07:01:35.321331+00:00 app[web.1]: 2020-05-16 07:01:35.321  INFO 4 --- [           
main] com.example.demo.DemoApplication         : No active profile set, falling back to 
default profiles: default
2020-05-16T07:01:37.629271+00:00 app[web.1]: 2020-05-16 07:01:37.628  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-05-16T07:01:37.676253+00:00 app[web.1]: 2020-05-16 07:01:37.675  INFO 4 --- [           
main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-16T07:01:37.676721+00:00 app[web.1]: 2020-05-16 07:01:37.676  INFO 4 --- [           
main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache 
Tomcat/9.0.35]
2020-05-16T07:01:37.821137+00:00 app[web.1]: 2020-05-16 07:01:37.820  INFO 4 --- [           
main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded 
WebApplicationContext
2020-05-16T07:01:37.821463+00:00 app[web.1]: 2020-05-16 07:01:37.821  INFO 4 --- [           
main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization  
completed in 2305 ms
2020-05-16T07:01:38.276493+00:00 app[web.1]: 2020-05-16 07:01:38.273  INFO 4 --- [           
main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 
'applicationTaskExecutor'
2020-05-16T07:01:38.454977+00:00 app[web.1]: 2020-05-16 07:01:38.454  INFO 4 --- [           
main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: ServletContext resource 
[/index.html]
2020-05-16T07:01:38.736300+00:00 app[web.1]: 2020-05-16 07:01:38.735  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with 
context path ''
2020-05-16T07:01:38.759357+00:00 app[web.1]: 2020-05-16 07:01:38.759  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Started DemoApplication in 4.771 seconds   
(JVM running for 5.887)
2020-05-16T07:03:01.250095+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-16T12:14:30.369161+00:00 heroku[router]: at=error code=H10 desc="App crashed" 
method=GET path="/" host=nameless-chamber-03761.herokuapp.com request_id=71365728-accd-48fa-
a5ed-d4f420b6cd3c fwd="77.181.100.181" dyno= connect= service= status=503 bytes= 
protocol=https
2020-05-16T12:14:30.742408+00:00 heroku[router]: at=error code=H10 desc="App crashed" 
method=GET path="/favicon.ico" host=nameless-chamber-03761.herokuapp.com 
request_id=24919523-0763-42f4-a9d2-8d148cdb97b8 fwd="77.181.100.181" dyno= connect= service= 
status=503 bytes= protocol=https
2020-05-16T12:16:03.537987+00:00 heroku[router]: at=error code=H10 desc="App crashed" 
method=GET path="/" host=nameless-chamber-03761.herokuapp.com request_id=5b7fb6ff-8868-4fc1-
b382-134f167bf327 fwd="77.181.100.181" dyno= connect= service= status=503 bytes= 
protocol=https
2020-05-16T12:28:00.000000+00:00 app[api]: Build started by user ****
2020-05-16T12:28:23.062523+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-16T12:28:22.893597+00:00 app[api]: Deploy 0e0889cc by user ****
2020-05-16T12:28:22.893597+00:00 app[api]: Release v4 created by user 
****
2020-05-16T12:28:27.000000+00:00 app[api]: Build succeeded
2020-05-16T12:28:29.021898+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno 
size. Custom settings will override them.
2020-05-16T12:28:29.029074+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: 
-XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-05-16T12:28:31.896036+00:00 app[web.1]:
2020-05-16T12:28:31.896107+00:00 app[web.1]: .   ____          _            __ _ _
2020-05-16T12:28:31.896138+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2020-05-16T12:28:31.896262+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-05-16T12:28:31.896402+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-05-16T12:28:31.896555+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-05-16T12:28:31.896661+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-05-16T12:28:31.899913+00:00 app[web.1]: :: Spring Boot ::        (v2.3.0.RELEASE)
2020-05-16T12:28:31.899975+00:00 app[web.1]:
2020-05-16T12:28:32.281294+00:00 app[web.1]: 2020-05-16 12:28:32.276  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on 
5452f1b4-a278-48c5-98e1-c75bdd084232 with PID 4 (/app/target/demo-0.0.1-SNAPSHOT.jar started 
by u10860 in /app)
2020-05-16T12:28:32.284125+00:00 app[web.1]: 2020-05-16 12:28:32.283  INFO 4 --- [           
main] com.example.demo.DemoApplication         : No active profile set, falling back to 
default profiles: default
2020-05-16T12:28:34.522151+00:00 app[web.1]: 2020-05-16 12:28:34.521  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8090 (http)
2020-05-16T12:28:34.554953+00:00 app[web.1]: 2020-05-16 12:28:34.554  INFO 4 --- [           
main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-16T12:28:34.555253+00:00 app[web.1]: 2020-05-16 12:28:34.555  INFO 4 --- [           
main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache  
Tomcat/9.0.35]
2020-05-16T12:28:34.675183+00:00 app[web.1]: 2020-05-16 12:28:34.674  INFO 4 --- [           
main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded  
WebApplicationContext
2020-05-16T12:28:34.675374+00:00 app[web.1]: 2020-05-16 12:28:34.675  INFO 4 --- [           
main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization  
completed in 2266 ms
2020-05-16T12:28:35.086773+00:00 app[web.1]: 2020-05-16 12:28:35.084  INFO 4 --- [           
main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 
'applicationTaskExecutor'
2020-05-16T12:28:35.242152+00:00 app[web.1]: 2020-05-16 12:28:35.241  INFO 4 --- [           
main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: ServletContext resource 
[/index.html]
2020-05-16T12:28:35.547679+00:00 app[web.1]: 2020-05-16 12:28:35.547  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8090 (http) with 
context path ''
2020-05-16T12:28:35.599875+00:00 app[web.1]: 2020-05-16 12:28:35.599  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Started DemoApplication in 4.748 seconds 
(JVM running for 6.57)
2020-05-16T12:29:57.002062+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-16T12:29:57.005306+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-16T12:30:02.809205+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno 
size. Custom settings will override them.
2020-05-16T12:30:02.814414+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: 
-XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2020-05-16T12:30:04.767929+00:00 app[web.1]:
2020-05-16T12:30:04.768123+00:00 app[web.1]: .   ____          _            __ _ _
2020-05-16T12:30:04.768241+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2020-05-16T12:30:04.768352+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-05-16T12:30:04.768464+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-05-16T12:30:04.768619+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-05-16T12:30:04.768732+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-05-16T12:30:04.770504+00:00 app[web.1]: :: Spring Boot ::        (v2.3.0.RELEASE)
2020-05-16T12:30:04.770574+00:00 app[web.1]:
2020-05-16T12:30:05.278180+00:00 app[web.1]: 2020-05-16 12:30:05.273  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on 
39dcf1b4-d45d-48df-9410-0e6628be2d64 with PID 4 (/app/target/demo-0.0.1-SNAPSHOT.jar started 
by u20284 in /app)
2020-05-16T12:30:05.279551+00:00 app[web.1]: 2020-05-16 12:30:05.279  INFO 4 --- [           
main] com.example.demo.DemoApplication         : No active profile set, falling back to   
default profiles: default
 2020-05-16T12:30:05.652996+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" 
method=GET path="/" host=nameless-chamber-03761.herokuapp.com request_id=5bdbb8c6-a22f-446f-
ac6f-a1c6aec362f5 fwd="77.181.100.181" dyno= connect= service= status=503 bytes= 
protocol=https
2020-05-16T12:30:07.744043+00:00 app[web.1]: 2020-05-16 12:30:07.743  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8090 (http)
2020-05-16T12:30:07.768880+00:00 app[web.1]: 2020-05-16 12:30:07.768  INFO 4 --- [           
main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-16T12:30:07.769379+00:00 app[web.1]: 2020-05-16 12:30:07.769  INFO 4 --- [           
main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache 
Tomcat/9.0.35]
2020-05-16T12:30:07.898340+00:00 app[web.1]: 2020-05-16 12:30:07.898  INFO 4 --- [           
main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded 
WebApplicationContext
2020-05-16T12:30:07.898510+00:00 app[web.1]: 2020-05-16 12:30:07.898  INFO 4 --- [           
main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization 
completed in 2476 ms
2020-05-16T12:30:08.282317+00:00 app[web.1]: 2020-05-16 12:30:08.281  INFO 4 --- [           
main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 
'applicationTaskExecutor'
2020-05-16T12:30:08.498359+00:00 app[web.1]: 2020-05-16 12:30:08.497  INFO 4 --- [           
main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: ServletContext resource 
[/index.html]
2020-05-16T12:30:08.728759+00:00 app[web.1]: 2020-05-16 12:30:08.728  INFO 4 --- [           
main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8090 (http) with 
context path ''
2020-05-16T12:30:08.759592+00:00 app[web.1]: 2020-05-16 12:30:08.759  INFO 4 --- [           
main] com.example.demo.DemoApplication         : Started DemoApplication in 4.84 seconds (JVM 
running for 5.945)
2020-05-16T12:31:05.938961+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" 
method=GET path="/" host=nameless-chamber-03761.herokuapp.com request_id=d5d37773-f24c-408f-
bc44-5db520817e47 fwd="77.181.100.181" dyno= connect= service= status=503 bytes= 
protocol=https
2020-05-16T12:31:30.779513+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-16T12:31:32.503518+00:00 heroku[router]: at=error code=H10 desc="App crashed" 
method=GET path="/" host=nameless-chamber-03761.herokuapp.com request_id=a8c93999-1d2c-4fe1-
ba38-520eeeaced15 fwd="77.181.100.181" dyno= connect= service= status=503 bytes= 
protocol=https

1 个答案:

答案 0 :(得分:1)

你快到了,

Heroku dynos公开了一个动态端口供您的应用绑定。此值在$PORT环境var中公开。

您可以在日志8080 8090 ...

中看到它

因此更新您的Procfile使其绑定到此端口:

web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/demo-0.0.1-SNAPSHOT.jar