6

I'm currently following John Thompson's Spring Framework Beginner to Guru course. I follow his step by step procedures on creating multi module maven project for spring pet clinic on spring boot. When I clicked package on my root module it says repackaged failed, unable to find main class.

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>repackage</goal>
                </goals>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </execution>
        </executions>
        </plugin>
    </plugins>
</build>

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

4 Answers 4

8

Remove

 <configuration>
       <skip>true</skip>
   </configuration>

and add "spring-boot.repackage.skip" property like the following:

<artifactId>pet-clinic-data</artifactId>
    <properties>
        <spring-boot.repackage.skip>true</spring-boot.repackage.skip>
    </properties>
6

you are using spring-boot-maven-plugin:2.1.6.RELEASE.

since Spring-Boot 2 you don't need the spring boot plugin anymore.

you can use the following code after declaring the artifact id of your module.

<artifactId>pet-clinic-data</artifactId>
<properties>
    <spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
1
  • 1
    spring-boot-maven-plugin is still required at least for my applications that are running with Spring Boot v2.1.7.RELEASE, Spring v5.1.9.RELEASE. If I comment out the plugin my application fails with "no main manifest attribute, in <your-app-here>.jar".
    – fedup
    Sep 18, 2019 at 2:05
6

The spring-boot-maven-plugin should only be in the pom.xml of the module that contains the main class. It looks like you have this plug in on (or inherited by) a simple jar module that the main module will use as a dependency.

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

The main class is annotated with @SpringBootApplication

0

Error speaks for itself. The executor cannot find your main class. It has nothing to do with your pom.xml. but has everything to do with the environment you are using to build and run your spring boot project.

If you are using IntelliJ, go to Run/Debug configuration (Add configuration on the screenshot, in your case it could be something else) and make sure your main class exits. Then tap your shift two times and type Invalidate Caches/Restart and do both. Then it should work as expected.

intellij config

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.