CodexBloom - Programming Q&A Platform

Maven plugin execution failure with Spring Boot in a multi-module setup using JDK 11

👀 Views: 0 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-19
maven spring-boot multi-module Java

I'm learning this framework and I need some guidance on I'm working with an scenario when trying to build my multi-module Spring Boot project using Maven. The build process fails with the behavior message: ``` [behavior] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.4:repackage (default) on project my-module: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.5.4:repackage failed: Unable to find main class -> [Help 1] ``` The project structure is as follows: ``` my-parent-project/ ├── pom.xml ├── my-module/ │ └── pom.xml └── another-module/ └── pom.xml ``` I've verified that my-module's `pom.xml` is properly inheriting from the parent POM and includes the necessary Spring Boot dependencies: ```xml <parent> <groupId>com.example</groupId> <artifactId>my-parent-project</artifactId> <version>1.0-SNAPSHOT</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.5.4</version> </plugin> </plugins> </build> ``` I have also included the `main` method in a class that is in the `src/main/java/com/example` directory: ```java package com.example; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MyModuleApplication { public static void main(String[] args) { SpringApplication.run(MyModuleApplication.class, args); } } ``` Despite this, the Maven build process want to seem to locate the main class. I have tried cleaning the project using `mvn clean`, ensured that the source directory is correctly set up, and even re-imported the project in my IDE (IntelliJ IDEA). Additionally, I checked the Maven version and confirmed that it's up to date (3.8.1). Has anyone encountered a similar scenario or can suggest what might be going wrong? Any insights would be greatly appreciated! What's the correct way to implement this?