Spring boot gradle "Could not find or load main class"

Viewed 9151

i have spring boot application that i want to package to jar. On run my application "java -jar app.jar" i caught error "Could not find or load main class com.software.appcreator.MyClass". I use gradle to build app, here is details of my build.gradle file(without dependencies):

https://pastebin.com/MvNgBDua

there are problems with formatting build.gradle, therefore posted on pastebin

what could be the reason for this situation? i pointed out main class in config and MyClass is present in final jar

3 Answers

If anyone facing the same issue, please put the below snippet in your build.gradle and rebuild.

springBoot {
    mainClassName = "your.class.Name"
}
Related