Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project fhirql: Fatal error compiling

I run the command mvn clean package I got above error my pom is:

enter image description here

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<parent>
    <groupId>ca.uhn.hapi.fhir</groupId>
    <artifactId>hapi-fhir</artifactId>
    <version>3.2.0</version>
</parent>

<groupId>com.canehealth</groupId>
<artifactId>fhirql</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
    <maven.compiler.target>1.11</maven.compiler.target>
    <maven.compiler.source>1.11</maven.compiler.source>
    <maven.build.timestamp.format>EEE, MMM dd yyyy, HH:mm Z</maven.build.timestamp.format>
</properties>

<dependencies>
    <!-- Compile -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-spring-boot-starter</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-jpaserver-base</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-jaxrsserver-base</artifactId>
        <version>${project.parent.version}</version>
    </dependency>

    <!--<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>-->

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.1</version>
    </dependency>

    <!-- Added -->
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-client</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-structures-dstu3</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-testpage-overlay</artifactId>
        <version>${project.parent.version}</version>
        <type>war</type>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-testpage-overlay</artifactId>
        <version>${project.parent.version}</version>
        <classifier>classes</classifier>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <!-- Optional -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <!-- Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-spring-boot-autoconfigure</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
    <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-base</artifactId>
        <version>${project.parent.version}</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.2.6.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <overlays>
                    <overlay>
                        <groupId>ca.uhn.hapi.fhir</groupId>
                        <artifactId>hapi-fhir-testpage-overlay</artifactId>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.11</source>
                <target>1.11</target>
            </configuration>
        </plugin>
    </plugins>
</build>

like image 539
Pankaj Khatiwada Avatar asked Apr 16 '20 05:04

Pankaj Khatiwada


People also ask

What are the common errors in Maven?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (default) on project binding-parent: Failed to create assembly: Error creating assembly archive jar-with-dependencies: You must set at least one file. EDIT2: mvn compile works fine, but mvn package fails with above error.

Why Maven-compiler-plugin is not working?

The main problem is that the compilation stuck because of the maven-compiler-plugin cannot compile and it is considered as an error compile. The reason for the incapability is because of invalid target release: 11. So, just remove by commenting the following element from the pom.xml file of the Java application project.

Why am I getting error code is not for default compiler?

The error occurred because the code is not for the default compiler used there. Paste this code in effective POM before the root element ends, after declaring dependencies, to change the compiler used.

How to fix Maven test not working on Windows 10?

Add the following in your pom.xml and do CTRL+S, it will automatically build the project. Now click on Run as >Maven Test. This error will definitely get solved.


3 Answers

I was facing the same issue, it works for me after changing version 11 to 1.8,

replace

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

with

<properties>
   <java.version>1.8</java.version>
  </properties>
like image 132
Hemanth Kumar Avatar answered Oct 17 '22 12:10

Hemanth Kumar


Since you have not pasted the complete error i believe you might have got below error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo: Fatal error compiling: error: invalid target release: 1.11 -

For maven compiler the correct JDK version is 1.8, 1.9, 1.10, 11, 12 ..

You could also simply replace the above <properties> tag with below

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

I have taken the above one from a sample project from Spring Initializr. You can remove the configuration from the maven compiler plugin too.

like image 27
Sachin Avatar answered Oct 17 '22 11:10

Sachin


You can change maven.compiler.target version from 1.11 to 11

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.release>11</maven.compiler.release>
</properties>
like image 1
Ahmed Saber Avatar answered Oct 17 '22 10:10

Ahmed Saber