Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find main class :bootRepackage

I got a problem with my gradle build. I use the standard proposed by the Spring Website (https://spring.io/guides/gs/rest-service/), but when I try to use gradle build, I got this error :

My gradle problem

It doesnt work for this gradle, but when I use another one (that I took when I was at school) it work perfectly.

like image 838
mfrachet Avatar asked Mar 20 '14 09:03

mfrachet


People also ask

What is bootRepackage in gradle?

When spring-boot is applied to your Gradle project a default task named bootRepackage is created automatically. The bootRepackage task depends on Gradle assemble task, and when executed, it tries to find all jar artifacts whose qualifier is empty (i.e. tests and sources jars are automatically skipped).

What is spring boot main class?

A Spring Boot application's main class is a class that contains a public static void main() method that starts up the Spring ApplicationContext. By default, if the main class isn't explicitly specified, Spring will search for one in the classpath at compile time and fail to start if none or multiple of them are found.


2 Answers

There are two possibilities

  1. Your source directory is not in the right location (use the sourceSets directive to fix this. your source directory should resemble something like src/main/java/your/package)
  2. Add this to indicate where your main class is

    springBoot {      mainClass = "hello.FileUploader" } 

I am pretty sure it is 1.

like image 67
Pradeep Avatar answered Sep 20 '22 08:09

Pradeep


I also have this problem, Here I solved the problem:

use org.springframework.boot:spring-boot-starter instead of org.springframework.boot:spring-boot-starter-web, if your project is only an module that will be used in other project.

Or Set the main class in gradle:

mainClassName = 'your.package.MainClass' 

Or Just disable the bootRepackage

bootRepackage {     enabled = false } 
like image 23
Bruce Avatar answered Sep 19 '22 08:09

Bruce