Deploying Spring Boot to Heroku

Viewed 37

So I'm in process of creating a small web app for myself using Java and Spring with Mongo. Right now I'm trying to deploy it to Heroku but without success so far.

I followed a list of commands to deploy my app from official Heroku website and also from YouTube tutorial and I'm facing an error that so far I couldn't solve.

I already had a project on GitHub and inserted these commands.

heroku login

git init ... I know i didn't have to since I have on git already

heroku git:remote -a tripadvisor-app-demo

and then

git add .

git commit -am "make it better"

git push heroku master

This is error stack trace:

    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project TripAdvisorApp: Fatal erro
r compiling: invalid target release: 11 -> [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/MojoExecutionException
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: b5d525882d9bb52d7175a5d79bcec430f37d6478
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version b5d525882d9bb52d7175a5d79bcec430f37d6478
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 tripadvisor-app-demo.
remote:
To https://git.heroku.com/tripadvisor-app-demo.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/tripadvisor-app-demo.git'

If you need anything else just ask I will provide, also I hope I provide all necessary stuff and describe process of how I tried to deploy it.

1 Answers

You build the application with a jdk verion lower than 11, but want the target level 11.

invalid target release: 11

install and use a jdk >=11 or set the maven.compiler.target to a lower java version.

Try mvn -version to see which java version you use.

Related