James
James

Reputation: 61

Spring Boot Multi-Module maven project repackage failed

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]

Upvotes: 6

Views: 7505

Answers (4)

Osam
Osam

Reputation: 169

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>

Upvotes: 8

fedup
fedup

Reputation: 1259

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

Upvotes: 6

Yonatan Gross
Yonatan Gross

Reputation: 417

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>

Upvotes: 6

Ilya Sereb
Ilya Sereb

Reputation: 2571

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

Upvotes: 0

Related Questions