Home > OS >  Heroku Git Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1: java 11
Heroku Git Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1: java 11

Time:10-21

I am trying to deploy my spring application to heroku. I wanted to use heroku git as in tutorial on heroku. I did:

git add .
git commit -am "make it better"
git push heroku master

but I am getting error:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project projectName: Fatal error compiling: invalid target release: 11 -> [Help 1]

So I spent about 2 hourse to solve it by any dependencies and changes in properties but nothing help. When I run mvn clean install in Intelijj Build is success - without ny error. That error only appears in cmd when I want to push it to master... Shortcut of my pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.4</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<version>0.0.1-SNAPSHOT</version>
<name>projectName</name>
<description>Demo project for Spring Boot</description>
<properties>
    <java.version>11</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
    …
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.22</version>
    </dependency>
        …
</dependencies>

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

    </plugins>
</build>

CodePudding user response:

There are a couple versions of answers to this question already on SO, and looks like the canonical one is here. One thing to consider is making your application a bit more portable to help avoid runtime version mismatches. If you Dockerize your app, you can make sure the JVM version in your pom.xml matches what's in your Dockerfile (spec of runtime env), and then you'll be able to test it locally knowing that if it works there, the container will likely run in a variety of environments. The Spring Boot Docker Docs should help. You can deploy it to Render (full disclosure: where I work) quite easily with a simple Dockerfile.

  • Related