无法将插件DSL与buildscript块

时间:2016-01-22 20:14:22

标签: spring gradle spring-boot gradle-plugin

我对Spring Boot和Gradle都很新。在尝试简化build.gradle脚本时,我遇到了以下问题。由于我使用Gradle 2.5,我决定利用Gradle的新插件DSL。不幸的是,我需要使用的其中一个插件spring-boot-gradle-plugin未包含在Gradle插件门户中。为了解决这个问题,我使用了该插件的旧buildscript {...}apply plugin:语法,并使用新的plugins {...}语法指定了其余的插件。结果是以下构建脚本:

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

plugins {
    id "io.spring.dependency-management" version "0.5.4.RELEASE"
    id "java"
    id "idea"
}

apply plugin: 'spring-boot'

repositories {
    mavenCentral()
}

dependencyManagement {
    imports {
        mavenBom 'com.vaadin:vaadin-bom:7.6.1'
    }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("com.vaadin:vaadin-spring-boot-starter")
    compile("com.h2database:h2")
    testCompile("junit:junit")
}

jar {
    baseName = 'my-spring-boot-app'
    version =  '0.1.0'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

但是,此构建脚本不起作用。运行gradle build时,我收到错误Plugin with id 'spring-boot' not found.这是尝试结合使用这两种语法的结果,还是我只是做些傻事?

1 个答案:

答案 0 :(得分:1)

我很傻。第6行语法错误。classpath之后不应该是冒号。

相关问题