0

Due to some circumstances I had to change the Kotlin main class in my Spring Boot project to Java. But when I build the project with Gradle i get an error: Main class name has not been configured and it could not be resolved

I fixed the building problem by setting sourceSets.main.java.srcDirs = ['src'] as stated in Gradle - Could not find or load main class but this messes up some things locally(Can't see Kotlin package in IntelliJ which includes the whole source code). I suspect there is a better way to setup a Kotlin project with a Java main class.

Thank you in advance

Radoslav Hubenov
  • 195
  • 1
  • 1
  • 10

1 Answers1

4

Have you tried using mainClassName property?

Add this to your build.gradle file:

    mainClassName = "com.my-package.my-another-package.MyMainClass"

Also, make sure you apply java plugin:

    apply plugin: 'java'
Romen
  • 103
  • 8