Gradle building rest spring app can’t find main class

I kept getting the follow error message. how to fix it.

FAILURE: Build failed with an exception.

Gradle building rest spring app can't find main class

  • What went wrong: Execution failed for task ‘:findMainClass‘. > org.gradle.api.tasks.SourceSetOutput.getClassesDir()Ljava/io/File;

plugins {
id ‘java’
id ‘idea’
id ‘eclipse’
id ‘org.springframework.boot’ version ‘2.1.7.RELEASE’
}

group ‘com.teamtreehouse’
version ‘1.0-SNAPSHOT’

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
compile ‘org.springframework.boot:spring-boot-starter-web:2.1.7.RELEASE’
}

 

 

Answers

springBoot {
mainClass = “main.java.hello.Application”
}

Note that mainclass  add your package name and main function name

 

both ./gradlew clean bootRun and ./gradlew clean build with java -jar build/libs/gs-rest-service-0.1.0.jar work well.

Good Luck

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *