Vlad
Vlad

Reputation: 199

Failed to execute goal org.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project (target 11)

I tried to deploy the simplest app from spring.io guides Guide

But I have some troubles.. What I did:

  1. Created project. (from spring.io tutorial)
  2. Downloaded heroku CLI
  3. Opened terminal in IntellijIdea
    3.1 git init
    3.2 git add .
    3.3 git commit -m "fd"
    3.4 git remote add heroke 'url'
    3.5 git push heroku master
  4. After the last command I have this error:
remote:        [INFO] BUILD FAILURE
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  12.608 s
remote:        [INFO] Finished at: 2020-01-23T18:20:18Z
remote:        [INFO] ------------------------------------------------------------------------
remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project milliapp: Fatal error 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: Verifying deploy...
remote:
remote: !       Push rejected to deploymilliapp.
remote:
To https://git.heroku.com/deploymilliapp.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/deploymilliapp.git'

Upvotes: 5

Views: 23086

Answers (7)

Hamza Daiz
Hamza Daiz

Reputation: 1

delete this properties from your pom.xml

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

and rebuild your project !

Upvotes: 0

Abhay Phougat
Abhay Phougat

Reputation: 410

The problem is you are telling maven to use JDK 11 to build your app but you have your java_home set to a different version. Change your java_home env variable to your java 11 installation and it would build it in 11.

Upvotes: 0

Moges Ashagrie
Moges Ashagrie

Reputation: 71

If using intelij,

  1. make system.properties file and put it in the root directory (where pom.xml is)
  2. in this file, write the appropriate versions e.g.
    java.runtime.version=11
    maven.version=3.6.2
  3. deploy again During this step, read the log file to see JDk 12 is installed by heroku

Upvotes: 4

Przemysław Sz
Przemysław Sz

Reputation: 41

You have to "tell" Heroku, that you want to run you app on Java 11. To do so add the system.properties file to your project (I did it in the main directory) and put the following line inside it:

java.runtime.version=11

It worked for me.

Upvotes: 4

Ravi Pullagurla
Ravi Pullagurla

Reputation: 512

In pom.xml file, comment below line in properties tag.

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

It worked for me.

Upvotes: 1

Kafarson
Kafarson

Reputation: 118

Second solution:

  1. Downgrade app to java 8
  2. Use maven-compiler-plugin 3.8.1 with that configuration:
   <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                    <testSource>8</testSource>
                    <testTarget>8</testTarget>
                    <showDeprecation>true</showDeprecation>
                    <compilerArgument>-Xlint:unchecked</compilerArgument>
                </configuration>
            </plugin>
        </plugins>

Upvotes: 0

Vlad
Vlad

Reputation: 199

Solved. Deleted this part of code

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

Upvotes: 14

Related Questions