Gradle build failed: Main class name has not been configured and it could not be resolved
If you are building multi-module project, and including a module that is not the springboot project, then you should put this on gradle.build which in the non-springboot module.
bootJar {
enabled = false
}
jar {
enabled = true
}
I ran into this error when I used kotlin and misplaced the main
method.
Wrong:
@SpringBootApplication
class Application {
fun main(args: Array<String>) {
runApplication<Application>(*args)
}
}
Fix (moved main
out of Application
):
@SpringBootApplication
class Application
fun main(args: Array<String>) {
runApplication<Application>(*args)
}
So, you can configure it. Pls try:
apply plugin: 'application'
mainClassName = 'com.example.WebApplication'