繁体   English   中英

无法将 Spring Boot 应用程序部署到 heroku

[英]Can not deploy spring boot application to the heroku

我尝试在 Heroku 上部署我的 Spring Boot 应用程序。 我将我的 github 连接到 Heroku 并为应用程序创建 clearDB。 部署成功后,我转到应用程序。 但是在 heroku 的日志中显示我2020-02-24T20:00:33.959429+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/auth/signin" host=linkedin-search.herokuapp.com request_id=52208cc6-575e-444b-bb45-c3910d49b175 fwd="134.249.164.109" dyno= connect= service= status=503 bytes= protocol=https

我的 Procfile 包含: web: java -jar target/Linkedin_Search-0.0.1-SNAPSHOT.jar我的 pom.xml 构建部分是:

 <build>
     <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.2.2.RELEASE</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals><goal>copy-dependencies</goal></goals>
                        </execution>
                    </executions>
            </plugin>
        </plugins>
    </build>

我按照 Heroku 开发中心的教程进行了所有操作,但没有任何效果。

根据您的日志,这是您问题的根本原因:

2020-02-27T13:58:45.159924+00:00 app[web.1]:在 target/Linkedin_Search-0.0.1-SNAPSHOT.jar 中没有主要清单属性

您创建的 JAR 文件在其清单中没有指定 Main 类。 如何解决这个问题真的取决于你的构建设置。 我看到您正在使用spring-boot-maven-plugin ,它通常会为您检测并设置该属性。 您可以尝试在该插件配置部分中明确配置它:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.2.2.RELEASE</version>
    <configuration>
        <mainClass>com.example.Main</mainClass> 
    </configuration>
</plugin>

您还可以在Procfile明确指定主类:

web: java -cp target/Linkedin_Search-0.0.1-SNAPSHOT.jar com.example.Main

我建议您在 GitHub 上推送您的应用程序,然后使用来自 heroku 的自动部署。 这更容易。 对我来说总是很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM