I am deploying with git. I am using this article. When I input the command git push heroku main
, it starts building, downloading somethings then after sometime, I get the error:
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]
and also:
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.
I created a new branch and added the project to it and tried to push to that branch with git push heroku <branchname>:main
, but it sill does not work. I have got the same error.
<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>
I started with the springboot demo project with, with mongodb, web and lambok dependencies.
It is just a very basic app that is working.
CodePudding user response:
This error usually means maven uses different java version.
Heroku uses OpenJdk8 by default- if you are using different version you need to specify the required version in system.properties
file. Something like:
java.runtime.version=17
Here are more details from Heroku: https://devcenter.heroku.com/articles/java-support#supported-java-versions