Skip to content
Latchkey

Maven "Failed to execute goal spring-boot:repackage" - Fix in CI

The Spring Boot Maven plugin tried to repackage your jar into an executable fat jar and failed - usually because it could not find a single main class, or there was no original jar to wrap.

What this error means

The build fails with Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:...:repackage, often with Unable to find a single main class from the following candidates or Source file ... must not be the same as the destination.

maven
[ERROR] Failed to execute goal
org.springframework.boot:spring-boot-maven-plugin:3.3.2:repackage
(repackage) on project app: Execution repackage of goal ... failed:
Unable to find a single main class from the following candidates
[com.example.App, com.example.Tools] -> [Help 1]

Common causes

Multiple or zero main classes

The plugin auto-detects the class with public static void main. With two candidates it cannot choose; with none it has nothing to launch.

No jar produced before repackage

A misconfigured packaging/jar step or a skipped package phase means there is no original artifact for repackage to wrap.

The plugin is bound to the wrong phase or module

Running repackage on a library module (one not meant to be executable) or before the jar is built triggers the failure.

How to fix it

Pin the main class

Tell the plugin exactly which class to launch when more than one main exists.

pom.xml
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <mainClass>com.example.App</mainClass>
  </configuration>
</plugin>

Skip repackage on library modules

Do not repackage modules that are not executable applications.

pom.xml
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration><skip>true</skip></configuration>
</plugin>

Run package so the jar exists

Repackage attaches to the package phase; build through it rather than running the goal alone.

Terminal
mvn -q clean package
# repackage runs as part of package, after the jar is built

How to prevent it

  • Set mainClass explicitly in multi-main projects.
  • Apply the Spring Boot plugin only to executable modules.
  • Build with package/verify in CI so the artifact exists before repackage.

Frequently asked questions

What causes ""Failed to execute goal spring-boot:repackage""?
The plugin auto-detects the class with public static void main. With two candidates it cannot choose; with none it has nothing to launch.
How do I fix "Failed to execute goal spring-boot:repackage"?
Tell the plugin exactly which class to launch when more than one main exists.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card