java - 找不到名称为 'runtime' 的 org.springframework.boot 配置

标签 java spring spring-boot gradle

尝试使用 gradle bootRun 运行我的程序时,错误显示
未能应用插件'org.springframework.boot'
未找到名称为“运行时”的配置
以下是我的build.gradle

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

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'

jar {
    baseName = 'blockchain-demo'
    version = '0.0.1'
}

war {
    baseName = 'blockchain-demo'
    version = '0.0.1'
}

application {
    mainClass = 'web.Application'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-devtools")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("junit:junit")
}

最佳答案

Spring Boot 2.5.0 支持 Gradle 6.8、6.9 或 7.x
有关 Gradle 7 配置的良好引用,请参见此处:https://docs.spring.io/spring-boot/docs/2.5.0/gradle-plugin/reference/htmlsingle/
这会让你离开地面:

plugins {
    id 'org.springframework.boot' version '2.5.0'
}

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

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web')
    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
}

repositories {
    mavenCentral()
}

关于java - 找不到名称为 'runtime' 的 org.springframework.boot 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67466790/

相关文章:

java - span html 标签的模式编译器

java - 当我尝试访问手机的外部存储器时应用程序崩溃

java - 将 Scanner 与自定义分隔符结合使用会跳过尾随的空标记

java - 使用 Spring @RestController 处理带 ZonedDateTime 参数的 HTTP GET

java - org.hibernate.AnnotationException : @OneToOne or @ManyToOne

Java - 以编程方式获取 Excel 和打开的 Office 电子表格以制表符分隔文件

java - Spring webflux,mongodb : Document is not saved into database

java - cacheable 如何使用其名称获取方法参数值

java - Spring Security 跨源

java - Spring Security @PreAuthorize