Failed to execute goal org.springframework.boot spring-boot-maven-plugin RELEASE repackage failed

While building the application using Maven we might get this error. There are different reasons for this error. Let’s see how to fix Failed to execute goal org.springframework.boot spring-boot-maven-plugin RELEASE repackage failed error.

The first thing we need to read the error message carefully and try to identify the root cause for this error. Generally, at the end of the line, we can get the exact root cause. For example below is a similar error that says the main class is missing from the spring boot application.

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:repackage (repackage) on project api-gateway: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:repackage failed: Unable to find main class -> [Help 1]

Second Solution– If spring-boot-maven-plugin is not needed, just remove it from pom.xml.

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

Third solution – Try to run mvn clean install first using bit bash or cmd.

Fourth solution – If nothing works, then try below steps.

  • Delete the .m2(we can find it inside C:\Users\yourname). Take backup for .m2 if needed.
  • Run mvn clean install
  • Reload the project from maven option.

Right click on project/maven/reload project

  • Invalidate cache and restart the IntelliJ(if you are using intellij)

Hope this helps!.

That’s all about Failed to execute goal org.springframework.boot spring-boot-maven-plugin RELEASE repackage failed.