2

Well i have already seen other post but couldnt solve my problem. Im trying to deploy springboot project to heroku, but this error occurs. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project : Fatal error compiling: invalid target release: 11 -> [Help 1]

Ive followed heroku guide:

$ git init
$ heroku git:remote -a <project>
$ git add .
$ git commit -am "first"
$ git push heroku master

Error:

remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD FAILURE
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  12.632 s
remote:        [INFO] Finished at: 2020-11-09T22:59:42Z
remote:        [INFO] ------------------------------------------------------------------------
remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project scoringsalud-backend: Fatal error compiling: invalid target releas
e: 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: d8ea942613535eca3b2881713d82bcbea9f267aa
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version d8ea942613535eca3b2881713d82bcbea9f267aa
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 scoringsalud.
remote:
To https://git.heroku.com/scoringsalud.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/scori

ngsalud.git'

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>scoringsalud-backend</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>scoringsalud-backend</name>
    <description>Backend Springboot and MongoDb project for Scoring Salud</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

What could be the problem? How to solve it? please i need help :(

  • Your error message already tells you what the issue is: `Fatal error compiling: invalid target release: 11`, i.e. building for an incompatible Java version. [This](https://stackoverflow.com/questions/63154787/maven-is-not-using-java-11-fatal-error-compiling-invalid-target-release-11) questions deals with the same issue, and should be of help. Next time, try to google the specific error messages that the application produces and you will be able to find a fix much faster. – filpa Nov 09 '20 at 23:33
  • Yes ive already done that, as i said i already searched and read other posts but couldnt solve my problem, thats the error i see after doing what they say in that post – Lucas Altamirano Nov 09 '20 at 23:36
  • 1
    In your `pom.xml`, you set the property `11`. Are you sure that both your source environment (where the compilation takes place, i.e. Heroku) and the target environment (where the application actually *runs*) both have Java 11 installed and have `JAVA_HOME` pointing to the correct directory? – filpa Nov 09 '20 at 23:41
  • 1
    Have you tried creating a `system.properties` file at the root of your project with : `java.runtime.version=11` https://devcenter.heroku.com/changelog-items/1489 – Xavier FRANCOIS Nov 10 '20 at 09:28

2 Answers2

2

change

<java.version>11</java.version>

to

<java.runtime.version>11</java.runtime.version>
0

I could solve it by downgrading everything to version 1.8, including my paths