springspring-bootpom.xmlinitializermainclass

Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1] [ERROR]


I've got a new project from spring boot initializer, the first run he work fine, but the next run i have this error : please add a mainClass,

The project is a spring boot application with kotlin and spring web. The main class is in the project and i don't change the pom which is defined from spring boot initializer.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.6.1</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
        <groupId>com.example</groupId>
        <artifactId>demo</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <name>demo</name>
        <description>Demo project for Spring Boot</description>
        <properties>
            <java.version>1.8</java.version>
            <kotlin.version>1.6.0</kotlin.version>
        </properties> ....

Solution

  • I've downloaded a new spring initializer project and copied my files from the old project. It is now working fine for me. I think the problem is my intellij configuration is bad.