-1

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> ....
Alfonso Tienda
  • 3,442
  • 1
  • 19
  • 34
mjedli
  • 1
  • 2

2 Answers2

0

Do you have the the application class ?

MyApplication.java

public static void main(String[] args) {
    SpringApplication.run(MyApplication.class, args);
}

If no, add this class in root

If class already exists try to run

mvn clean package spring-boot:repackage 
4EACH
  • 2,132
  • 4
  • 20
  • 28
0

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.

Greg Ruhl
  • 1,060
  • 2
  • 9
  • 27
mjedli
  • 1
  • 2