Home > database >  What is wrong with my pom file causing this build error?
What is wrong with my pom file causing this build error?

Time:12-28

I have reinstall Java and reset JAVA_HOME to make sure maven is using the correct java version but am continuing to receive this error:

#9 67.23 [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:repackage (repackage) on project backend: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.1' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 60.0

I currently am getting these outputs:

zack project-portfolio >> java --version openjdk 19.0.1 2022-10-18 OpenJDK Runtime Environment Homebrew (build 19.0.1) OpenJDK 64-Bit Server VM Homebrew (build 19.0.1, mixed mode, sharing) zack project-portfolio >> mvn --v Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /usr/local/Cellar/maven/3.8.6/libexec Java version: 19.0.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/19.0.1/libexec/openjdk.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "13.0.1", arch: "x86_64", family: "mac".

What could be wrong with the following pom.xml file as I feel it is a dependency issue? Or could it be an issue with my Dockerfile?:

<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>3.0.1</version>
</parent>
<groupId>com</groupId>
<artifactId>backend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>backend</name>
<description>Backend for portfolio</description>
<properties>
    <java.version>1.7</java.version>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</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.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <finalName>project</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

CodePudding user response:

Java 17 is the minimum requirement for spring boot 3.x version. Refer this link for more information. Set the Java environment to JDK17 to resolve the error.

References https://javaalmanac.io/bytecode/versions/

CodePudding user response:

You need Java 17 to run spring boot 3.

  • Related