简体   繁体   中英

Gradle building Spring Boot library without Main Class

I am trying to build a Spring Boot/Gradle project and create a jar without a main class. My purpose is that this project is a library that will be pulled in by other projects therefore the library project does not require a main class to run. Unfortunately, no matter what kind of gradle config I write I keep getting errors when I try to build install about not having a main class or not being able to find the bootJar task.

Here's what my gradle file looks like:

plugins {
    id 'org.springframework.boot' version '2.1.7.RELEASE' apply false
}

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

dependencyManagement {
    imports {
        mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
    }
}

repositories {
    mavenCentral()
}

jar {
    enabled = true
}

bootJar.dependsOn fooTask

But when I run this I get the following error:

Could not get unknown property 'bootJar' for root project 'foo-library' of type org.gradle.api.Project.

What in my configuration needs to change?

Disable bootJar in your build.gradle

bootJar {
   enabled = false
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM