简体   繁体   English

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

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

I try to deploy my spring boot application on the Heroku .我尝试在 Heroku 上部署我的 Spring Boot 应用程序。 I connect my github to the Heroku and create clearDB for the application.我将我的 github 连接到 Heroku 并为应用程序创建 clearDB。 After when deploy success I go to the application.部署成功后,我转到应用程序。 But in the logs of the heroku shows me 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但是在 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

My Procfile contains that: web: java -jar target/Linkedin_Search-0.0.1-SNAPSHOT.jar My pom.xml build section is:我的 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>

I do all as in the tutorial on the Heroku dev center but nothing is works.我按照 Heroku 开发中心的教程进行了所有操作,但没有任何效果。

According to your logs this is the root cause for your issue:根据您的日志,这是您问题的根本原因:

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

The JAR file you create does not have the Main class specified in its manifest.您创建的 JAR 文件在其清单中没有指定 Main 类。 How to fix this really depends on your build setup.如何解决这个问题真的取决于你的构建设置。 I see you're using spring-boot-maven-plugin which usually detects and sets that attribute for you.我看到您正在使用spring-boot-maven-plugin ,它通常会为您检测并设置该属性。 You can try to configure it explicitly in that plugins configuration section:您可以尝试在该插件配置部分中明确配置它:

<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>

You could also specify the main class explicitly in your Procfile :您还可以在Procfile明确指定主类:

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

i recomend you to push your apllication on GitHub and then use the automatic deploy from heroku.我建议您在 GitHub 上推送您的应用程序,然后使用来自 heroku 的自动部署。 it is more easy.这更容易。 always work fine for me.对我来说总是很好。

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

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