0
import org.springframework.boot.runApplication
import org.springframework.boot.SpringApplication

@SpringBootApplication
open  class MyApplication

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

Error: unable to find or unable to load the main class

Why can't that run, but this can?

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.SpringApplication

@SpringBootApplication
open class MyApplication

fun main(args: Array<String>) {
    SpringApplication.run(MyApplication::class.java, *args)
}

1 Answer 1

1

You are missing following import in your Kotlin code:

import org.springframework.boot.autoconfigure.SpringBootApplication

Adding it should fix the problem.

On the other hand, this import is not necessary:

import org.springframework.boot.SpringApplication
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.