我正在创建一个根本没有主类的库。该库使用Spring,该Spring具有正在寻找mainClassName的应用程序插件。我为mainClassName添加了null,但我正在寻找更好的解决方案。我四处搜寻,发现添加bootJar.enabled = false不会寻找mainClassName,但没有帮助。有人可以帮我吗?

    ext {
        springBootVersion = '2.2.1.RELEASE'
        satelliteVersion = '2.12.3'
    }

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        classpath('org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE') {
            exclude group: 'org.slf4j'
            exclude module: 'spring-boot-starter-log4j'
        }
    }
}

plugins {
    id 'java'
    id 'groovy'
    id 'idea'
    id 'distribution'
}
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

repositories {
    mavenLocal()
    mavenCentral()
}
bootJar.enabled = false
apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
version = System.getenv('CI') == 'drone' ? "1.0.${System.getenv('DRONE_BUILD_NUMBER')}" : "local"
tasks.validateYaml.enabled = false

dependencies {
    implementation "org.springframework.boot:spring-boot-starter-mail:${springBootVersion}"

    implementation group: 'com.google.guava', name: 'guava', version: '18.0'
    implementation group: 'commons-io', name: 'commons-io', version: '2.6'

}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives sourcesJar
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            artifact tasks.sourcesJar
        }
    }
}
configurations.all {
    exclude module: 'spring-boot-starter-logging'
    exclude group: 'ch.qos.logback'
    exclude module: 'logback-access-spring-boot-starter'

}

我收到以下错误
A problem was found with the configuration of task ':startScripts' (type 'CreateStartScripts').
> No value has been specified for property 'mainClassName'.


最佳答案

新增中

startScripts.enabled = false
bootJar.enabled = false
distTar.enabled = false

解决了我的问题。谢谢

10-02 22:46