Home > Net >  Spring Boot with spring version 2.5.7 fails repackage with jdk 1.8
Spring Boot with spring version 2.5.7 fails repackage with jdk 1.8

Time:02-10

When running a maven package goal

mvn clean package

The build throws the error:

goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1' 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 52.0

my JAVA_HOME is pointing to jdk1.8.0_73

How can i get spring-boot-maven-plugin running with repackage goal?

Below is the maven build configuration in my module.

<build>
<resources>
    <resource>
        <directory>resources</directory>
    </resource>
</resources>
<plugins>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <configuration>
            <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
            <webResources>
                <resource>
                    <directory>src/main/resources</directory>
                    <include>*.*</include>
                    <targetPath>/WEB-INF/classes</targetPath>
                </resource>
                <resource>
                    <directory>src/main/webapp/errors</directory>
                    <include>*.*</include>
                    <targetPath>/errors/</targetPath>
                </resource>
            </webResources>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <mainClass>com.services.MyAApp</mainClass>
            <layout>war</layout>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</plugins>

CodePudding user response:

Version of 'spring-boot-maven-plugin' plugin used in you pom.xml is 3.0.0-M1, which can be used only with Java 17 or newer. Switch to 2.5.7, if it's really version which you want to use for spring boot project.

  • Related