spring - Gradle 构建失败 : Main class name has not been configured and it could not be resolved

标签 spring gradle

我正在按照 this 使用 Spring 构建 RESTful Web 服务指导。我正在使用抓取来构建应用程序,但我的构建失败了。

我在 Windows 10 机器上使用了“build gradle”命令。

这是毕业代码:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
    baseName = 'gs-rest-service'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

我收到以下错误:

任务“:bootJar”执行失败。

Main class name has not been configured and it could not be resolved

最佳答案

在构建包含 springboot 项目之外的模块的多模块项目时,模块的 build.gradle必须包含:

bootJar {
    enabled = false
}

jar {
    enabled = true
}

关于spring - Gradle 构建失败 : Main class name has not been configured and it could not be resolved,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56861256/

相关文章:

android - Android依赖项 'com.android.support:support-core-utils'对于编译(27.1.1)和运行时(28.0.0)具有不同的版本

java - 导出属性时 Gradle 错误消息 "Could not find property on project"

eclipse - Eclipse Mars.2中没有Gradle文件语法突出显示

java - Spring JPA 存储库方法在查询后不设置实体的值

java - Spring 3 MVC : Expose session scoped bean in MVC Controller method arguments

java - 使用 Spring Data 时如何确定是否插入重复项?

spring - 在 Oracle Timestamp 列中以 UTC 格式保存日期

java - 在调用代码中捕获 Feign 客户端的错误状态并向上游报告错误

android - 应用程序 bundle 引起致命异常:android.content.res.Resources $ NotFoundException

java - 在 gradle 中添加 github 库作为依赖项