'What magic happens in kotlin

I have kotlin + spring boot app. I done some development in my feature branch committed and returned to dev branch, built app and just tried to start it in intellij idea, but get an error

Error: Main method not found in class com.test.Application, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

I could swear it worked and moreover it works.

@SpringBootApplication
@EnableScheduling
@EnableConfigurationProperties()
class Application {

}

fun main(args: Array<String>) {
    runApplication<Application>(*args)
}

Where i should look for reason of this issue - kotlin, intellij idea? Thanks



Solution 1:[1]

Your main() function is a package-level (AKA ‘top-level’) function, because it's not defined within your Application class (or, more usually for main(), its companion object).

And in Kotlin/JVM, package-level functions are treated as belonging to a special class named for the source file, with a Kt suffix.

So in this case, you should specify the main class as com.test.ApplicationKt.

(The language docs describe this here.?This is one of those implementation details that you normally don't need to know; it's only important when specifying your main class, or calling a package-level function from Java.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1