簡體   English   中英

將 springboot 應用程序部署到 heroku 時出錯

[英]Error with deploying springboot app to heroku

我正在使用 git 進行部署。 我正在使用這篇文章 當我輸入命令git push heroku main時,它開始構建,下載一些東西,然后過了一段時間,我得到了錯誤:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project assessment: Fatal error compiling: invalid target release: 17 -> [Help 1]

並且:

remote:        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote:        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote:        [ERROR] 
remote:        [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote:        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
remote:  !     ERROR: Failed to build app with Maven
remote:        We're sorry this build is failing! If you can't find the issue in application code,
remote:        please submit a ticket so we can help: https://help.heroku.com/
remote: 
remote:  !     Push rejected, failed to compile Java app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: ----
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version ----
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to app.

我創建了一個新分支並將項目添加到其中並嘗試使用git push heroku <branchname>:main推送到該分支,但它仍然不起作用。 我有同樣的錯誤。

<build>

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

<groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.3</version>
        <relativePath/>


<!--    ...   -->

<properties>
        <java.version>17</java.version>
    </properties>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

我從 springboot 演示項目開始,使用 mongodb、web 和 lambok 依賴項。

它只是一個正在運行的非常基本的應用程序。

此錯誤通常表示 maven 使用不同的 java 版本。

Heroku 默認使用 OpenJdk8 - 如果您使用不同的版本,您需要在system.properties文件中指定所需的版本。 就像是:

java.runtime.version=17

以下是 Heroku 的更多詳細信息: https://devcenter.heroku.com/articles/java-support#supported-java-versions

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM