Dockerfile can not build jar file : Main class name has not been configured Dockerfile can not build jar file : Main class name has not been configured docker docker

Dockerfile can not build jar file : Main class name has not been configured


Just to make a formal answer from my comment since it worked. As I explained in the comment: When we use Kotlin, the real main class is generated behind the scenes with Kt suffix, you should find it in your build folder after running gradle bootJar.

You should update the mainClassName to com.test.config.ConfigServerAppKt as shown below:

tasks.withType<BootJar> {    archiveFileName.set("app.jar")    mainClassName = "com.test.config.ConfigServerAppKt"}


As explained in the Kotlin docs :

All the functions and properties declared in a file app.kt inside a package org.example, including extension functions, are compiled into static methods of a Java class named org.example.AppKt.

So your main method will be part of java class named ConfigServerAppKt after compilation. So you should change your mainClassName to com.test.config.ConfigServerAppKt.