spring-projects/spring-boot · error · MojoExecutionException

Unable to find a suitable main class, please add a 'mainClas

Error message

Unable to find a suitable main class, please add a 'mainClass' property

What it means

Error "Unable to find a suitable main class, please add a 'mainClass' property" thrown in spring-projects/spring-boot.

Source

Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringBootApplicationClassFinder.java:50

 */
abstract class SpringBootApplicationClassFinder {

	private static final String SPRING_BOOT_APPLICATION_CLASS_NAME = "org.springframework.boot.autoconfigure.SpringBootApplication";

	static String findSingleClass(File classesDirectory) throws MojoExecutionException {
		return findSingleClass(List.of(classesDirectory));
	}

	static String findSingleClass(List<File> classesDirectories) throws MojoExecutionException {
		try {
			for (File classesDirectory : classesDirectories) {
				String mainClass = MainClassFinder.findSingleMainClass(classesDirectory,
						SPRING_BOOT_APPLICATION_CLASS_NAME);
				if (mainClass != null) {
					return mainClass;
				}
			}
			throw new MojoExecutionException("Unable to find a suitable main class, please add a 'mainClass' property");
		}
		catch (IOException ex) {
			throw new MojoExecutionException(ex.getMessage(), ex);
		}
	}

}

View on GitHub (pinned to 5b2dbdbb8b)

When it happens

Trigger: Thrown at build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/SpringBootApplicationClassFinder.java:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of spring-projects/spring-boot@5b2dbdbb8b (2026-08-04). Data as JSON: /data/errors/9318a06ae62b3e1a.json. Report an issue: GitHub.