首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未解决的符号:mainClassName

问未解决的符号:mainClassName
EN

Stack Overflow用户
提问于 2022-10-23 15:52:49
回答 1查看 46关注 0票数 0

我有一个SpringBoot项目,其build.gradle如下:

代码语言:javascript
复制
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile


plugins {
    id("org.springframework.boot") version "2.7.0"
    id("io.spring.dependency-management") version "1.0.9.RELEASE"
    kotlin("jvm") version "1.7.0"
    kotlin("plugin.spring") version "1.7.0"
    kotlin("plugin.jpa") version "1.6.21"
    id("org.flywaydb.flyway") version "6.4.4"
}

group = "com.planes"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.apache.tomcat.embed:tomcat-embed-jasper")
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-validation")
    implementation("org.springframework.boot:spring-boot-starter-security")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("io.jsonwebtoken:jjwt:0.9.0")
    implementation("org.postgresql:postgresql")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
    testImplementation("org.springframework.security:spring-security-test")
}

tasks.withType<Test> {
    useJUnitPlatform()
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

springBoot {
    mainClassName = "com.planes.planesserver.DemoApplication"
}

当我运行Gradle包装器任务时,我得到以下错误:“未解决的引用: mainClassName”

这发生在我将SpringBoot从2.2版升级到2.7版和gradle从版本5更新到6.9.3之后

在以前的配置中,项目可以编译得很好。对于这个新的配置,我还需要做什么调整吗?

谁能提个建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-23 17:50:26

在SpringBoot2.4中,他们更改了主类名属性的名称和类型,参见Springboot 2.4发行说明中的

您需要按以下方式更新构建脚本:

代码语言:javascript
复制
springBoot {
    // before springboot 2.4
    // mainClassName = "com.planes.planesserver.DemoApplication"

    // since springboot 2.4 : 
    mainClass.set( "com.planes.planesserver.DemoApplication")
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74172581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档