[英]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.