在将应用程序部署到Heroku(Spring Boot)时出现错误。

3

我想要做的是将我的Spring Boot应用程序部署到Heroku(使用Git和Heroku CLI)。

但是,每次我将我的repo推送到Heroku时,在终端中使用"$git push heroku master"之后,这些错误都会出现。

    remote:        [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.2:repackage (repackage) on project UserEditor: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.6.2:repackage failed: Unable to find main class -> [Help 1]
remote:        [ERROR] 
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/PluginExecutionException
remote: 
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: 33efb1c07b67aebd548c83b47099d3a66a2efed2
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 33efb1c07b67aebd548c83b47099d3a66a2efed2
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 myhome-app-1.
remote: 
To https://git.heroku.com/myhome-app-1.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myhome-app-1.git' ```

1个回答

4

这个错误是因为您正在使用Java 8以上的版本,而免费部署的Heroku仅允许使用Java 8版本。因此,请在pom.xml中将Java版本更改为8并重新构建Maven。

之后,在本地系统中运行项目以验证是否没有错误,因为Java-8不包含您在项目中可能使用的所有函数。


非常感谢您的回答,由于我还是编程世界的新手,所以我不太确定如何做到这一点。您有没有好的视频推荐讲解这个问题? - user123

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接