gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 02:39:32 30 4
gpt4 key购买 nike

我正在按照 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com