当前位置: 首页 > 知识库问答 >
问题:

在Heroku成功部署后出现应用程序错误

毋宏茂
2023-03-14

我有一个spring-boot项目在IntelliJ IDE中运行良好,我试图将其部署在Heroku服务器上。该项目部署成功,但当我试图从POSTMAN访问它时,我得到了503错误:服务不可用。

以下是从Heroku成功部署后的日志记录:

-----> Building on the Heroku-20 stack
-----> Java app detected
-----> Installing JDK 1.8... done
-----> Executing Maven
       $ ./mvnw -DskipTests clean dependency:list install
       [INFO] Scanning for projects...
       [INFO] 
       [INFO] ----------------< io.slcoder:authentication-server >-----------------
       [INFO] Building authentication-server 0.0.1-SNAPSHOT
       [INFO] --------------------------------[ war ]---------------------------------
       [INFO] 
       [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ authentication-server ---
       [INFO] 
       [INFO] --- maven-dependency-plugin:3.1.2:list (default-cli) @ authentication-server ---
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ authentication-server ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Using 'UTF-8' encoding to copy filtered properties files.
       [INFO] Copying 1 resource
       [INFO] Copying 1 resource
       [INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ authentication-server ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 9 source files to /tmp/build_d09a68b1_/target/classes
       [INFO] 
       [INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ authentication-server ---
       [INFO] Using 'UTF-8' encoding to copy filtered resources.
       [INFO] Using 'UTF-8' encoding to copy filtered properties files.
       [INFO] skip non existing resourceDirectory /tmp/build_d09a68b1_/src/test/resources
       [INFO] 
       [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ authentication-server ---
       [INFO] Changes detected - recompiling the module!
       [INFO] Compiling 1 source file to /tmp/build_d09a68b1_/target/test-classes
       [INFO] 
       [INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ authentication-server ---
       [INFO] Tests are skipped.
       [INFO] 
       [INFO] --- maven-war-plugin:3.3.1:war (default-war) @ authentication-server ---
       [INFO] Packaging webapp
       [INFO] Assembling webapp [authentication-server] in [/tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT]
       [INFO] Processing war project
       [INFO] Building war: /tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT.war
       [INFO] 
       [INFO] --- spring-boot-maven-plugin:2.4.1:repackage (repackage) @ authentication-server ---
       [INFO] Replacing main artifact with repackaged archive
       [INFO] 
       [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ authentication-server ---
       [INFO] Installing /tmp/build_d09a68b1_/target/authentication-server-0.0.1-SNAPSHOT.war to /tmp/codon/tmp/cache/.m2/repository/io/slcoder/authentication-server/0.0.1-SNAPSHOT/authentication-server-0.0.1-SNAPSHOT.war
       [INFO] Installing /tmp/build_d09a68b1_/pom.xml to /tmp/codon/tmp/cache/.m2/repository/io/slcoder/authentication-server/0.0.1-SNAPSHOT/authentication-server-0.0.1-SNAPSHOT.pom
       [INFO] ------------------------------------------------------------------------
       [INFO] BUILD SUCCESS
       [INFO] ------------------------------------------------------------------------
       [INFO] Total time:  8.024 s
       [INFO] Finished at: 2021-01-28T20:29:08Z
       [INFO] ------------------------------------------------------------------------
-----> Discovering process types
       Procfile declares types -> (none)
-----> Compressing...
       Done: 149.5M

Heroku的申请日志:

2021-01-28T21:06:14.000000+00:00 app[api]: Build started by user slcoder@gmail.com
2021-01-28T21:06:43.212587+00:00 app[api]: Release v12 created by user slcoder@gmail.com
2021-01-28T21:06:43.212587+00:00 app[api]: Deploy f113390b by user slcoder@gmail.com
2021-01-28T21:06:50.000000+00:00 app[api]: Build succeeded
2021-01-28T21:06:55.588865+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=8710722d-c858-423a-bb8b-9268ef8318f3 fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-28T21:06:59.516531+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=0d6f4102-5dba-44b4-b717-d6d732d236bd fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T00:17:50.789994+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=fcba05fd-3c76-4830-af3e-dfc697b2f190 fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T00:17:52.530644+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=77736faf-0206-49dc-80be-3a1c0b5f061a fwd="196.74.101.204" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T11:20:59.963444+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=authentication-server-app.herokuapp.com request_id=c66098e0-1893-4d3f-90e3-e08f3afe0cea fwd="160.177.175.70" dyno= connect= service= status=503 bytes= protocol=https
2021-01-29T11:21:02.909523+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=authentication-server-app.herokuapp.com request_id=ee94b09c-f8c8-4783-a951-0c511007f93f fwd="160.177.175.70" dyno= connect= service= status=503 bytes= protocol=https
<?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.4.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>io.slcoder</groupId>
    <artifactId>authentication-server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>authentication-server</name>
    <description>Server dedicated to authentication</description>
    <packaging>war</packaging>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

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

</project>

spring.datasource.url=jdbc:mysql://zt9j9hwaktmzqprk:eayk987igm1t1shd@esilxl0nthgloe1y.chr7pe7iynqr.eu-west-1.rds.amazonaws.com:3306/vqa34ov9ga2iumfm
spring.datasource.username=zt9j9hwaktmzqprk
spring.datasource.password=****************
spring.datasource.initialization-mode = always
spring.datasource.max-active=10

有人能帮帮我吗?提前谢了。

共有1个答案

唐海阳
2023-03-14

最终,核心问题是Heroku不知道如何运行您的应用程序。您通常告诉Heroku如何使用ProcFile运行应用程序。

但是,由于您正在运行Spring Boot,我们将检测到这一点,并为您编写一个Procfile。这里没有发生这种情况,因为您将应用程序打包为WAR文件,我们不能作为独立的应用程序运行。

如果您将Spring Boot打包改为JAR,Heroku应该会将您的应用程序检测为Spring Boot应用程序,您甚至不需要procfile。尝试在pom.xml中将 WAR 更改为 JAR

 类似资料:
  • 每次都会出现以下错误!有相同的修复方法吗? 2021-10-07T10:47:31.133956 00:00heroku[路由器]: at=错误代码=H10 desc="应用程序崩溃"方法=GET路径="/"主机=zturlshortener.herokuapp.comrequest_id=c2f90e55-52f5-4955-a1d6-4028456cfddb fwd="103.199.173.

  • 错误:命令错误,退出状态为1:Command://app/.heroku/python/bin/python/app/.heroku/python/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel/tmp/tmp3b4z4ntu cwd://tmp/pip-i

  • 我的应用程序似乎总是在部署后崩溃。 2015-07-21T13:29:28.127452+00:00 Heroku[router]:at=error code=h10 desc=“应用程序崩溃”method=get path=“/api/v1/sessions”host=calm-hamlet-5165.herokuapp.com request_id=69711e3a-913e-45ed-b4b

  • 我正在Heroku上部署一个网站,但我在尝试运行“Heroku open”时收到了“应用程序错误”。 我相信我已经成功地将文件推送到Heroku中,这是我的“git推送heroku master”代码的一部分: 当我运行“heroku config-s | grep PATH”时,我得到了 我正在使用Ruby 1.9.3和Rails 4.0.0 文件夹 宝石环境 箱/轨道 垃圾箱/包裹 仓/耙

  • 编辑问题以包括所需的行为、特定问题或错误以及重现问题所需的最短代码。这将帮助其他人回答问题。 这是我第一个使用节点的代码,它在locahost:3000上运行良好。下面是我检查日志后的错误:

  • 我正在尝试将我的应用程序部署到Heroku,但似乎存在一些问题。每次我尝试: 我的heroku日志告诉我,我的应用程序崩溃了,我错过了“调试器”宝石。我在Heroku上找到了这条线索和这一页。当我尝试安装“byebug”gem时,bundle告诉我它不会安装在Ruby 1.9.3上,当我按照Heroku的建议将“debugger”gem放在gem文件的开发组中时,我仍然会收到相同的错误。 我也更新