How do I specify a Kotlin function as the `mainCla...
# spring
d
How do I specify a Kotlin function as the
mainClassName
in the
springBoot
section of the build.gradle.kts? (The rest of the details in the thread)
First, I'm using Windows. 😞 I'm also using the setup in the Spring Boot Kotlin tutorial (https://spring.io/guides/tutorials/spring-boot-kotlin/). I ran into a bunch of issues when the classpath/filename became too large. My Application looks exactly like this (but different names of course)
Copy code
package <http://com.example.blog|com.example.blog>

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication

@SpringBootApplication
class BlogApplication

fun main(args: Array<String>) {
  runApplication<BlogApplication>(*args)
}
This used to work fine. However, because of the Windows issue, I needed to use the
id("com.github.ManifestClasspath") version "0.1.0-RELEASE"
plugin. In doing that, I got this
Main class name has not been configured and it could not be resolved
.
I'm fairly certain I need to use:
Copy code
springBoot {
    mainClassName = ""
}
However, since the main is a Kotlin function, how do I specify that here?
v
Copy code
mainClassName = "com.example.my.ApplicationKt"
That Kt part is necessary so it will be whatever your class name is + ‘Kt’
d
Thank you @viralshah! It worked.
Well, I got further than I did before anyway. 🙂
v
what’s wrong
d
It might be an application error (i.e., I caused it). Still investigating.
v
good luck 🤞
d
Yup, just something on my side. Fix it. It all works. Thanks again!