https://kotlinlang.org logo
#spring
Title
# spring
d

Dave Jensen

01/22/2020, 7:04 PM
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

viralshah

01/22/2020, 8:03 PM
Copy code
mainClassName = "com.example.my.ApplicationKt"
That Kt part is necessary so it will be whatever your class name is + ‘Kt’
d

Dave Jensen

01/22/2020, 11:25 PM
Thank you @viralshah! It worked.
Well, I got further than I did before anyway. 🙂
v

viralshah

01/22/2020, 11:28 PM
what’s wrong
d

Dave Jensen

01/22/2020, 11:34 PM
It might be an application error (i.e., I caused it). Still investigating.
v

viralshah

01/23/2020, 12:00 AM
good luck 🤞
d

Dave Jensen

01/23/2020, 12:03 AM
Yup, just something on my side. Fix it. It all works. Thanks again!
6 Views