-2

I try to create spring-boot-starter. I create a simple spring-boot module with this Gradle file:

plugins {
    id 'org.springframework.boot' version '2.1.3.RELEASE'
    id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'my.domain'
version = '0.0.1-SNAPSHOT'

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    annotationProcessor "org.springframework.boot:spring-boot-autoconfigure-processor"
}

And one class:

@SpringBootApplication
public class ApiSpringBootStarterApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiSpringBootStarterApplication.class, args);
    }

}

It builds successfully. But if I delete ApiSpringBootStarterApplication class I get an error:

* What went wrong:
Execution failed for task ':api-spring-boot-starter:bootJar'.
> Main class name has not been configured and it could not be resolved
ip696
  • 6,574
  • 12
  • 65
  • 128
  • 2
    If this is a starter then don't apply the Spring Boot plugin. That plugin is only ment for packaging spring boot applications. Your starter generally doesn't contain code but only dependencies and thus a `pom.xml` and/or gradle dependency information. – M. Deinum Apr 09 '19 at 08:31
  • Why would you like to remove ApiSpringBootStarterApplication? This class is the entry point for this application and it is required. – MariuszS Apr 09 '19 at 11:17
  • @ MariuszS because I create `spring-boot-starter`. I solved this problem, I create just gradle module instead spring-boot application – ip696 Apr 09 '19 at 11:22

2 Answers2

0

Remove org.springframework.boot from plugins. This plugin is aimed to build executable jar for your project. In case of starter you don't need to do this.

Ref: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/

By analogy, the same would be if you were using maven and spring-boot-maven-plugin.

amseager
  • 5,795
  • 4
  • 24
  • 47
-2

The JVM searching for the main class for start the application without the main class you can't start the application.

Why are you deleted the ApiSpringBootStarterApplication ? Is your main class.

MarS
  • 74
  • 2
  • 9