Spring Boot Multi-Module maven project repackage failed
Asked Answered
C

4

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]

Cambium answered 24/7, 2019 at 16:33 Comment(0)
S
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>
Scherzando answered 19/10, 2019 at 14:37 Comment(0)
H
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>
Hanan answered 4/8, 2019 at 19:40 Comment(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".Viminal
V
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

Viminal answered 18/9, 2019 at 1:22 Comment(0)
F
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

Favored answered 24/7, 2019 at 17:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.