2016-01-22 50 views
1

我對Spring Boot和Gradle都很陌生。在試圖簡化我的build.gradle腳本時,我遇到了以下問題。由於我使用Gradle 2.5,我決定利用Gradle的新插件DSL。不幸的是,我需要使用的插件之一spring-boot-gradle-plugin未包含在Gradle插件門戶中。要解決這個問題,我使用了該插件的舊buildscript {...}apply plugin:語法,並在新的plugins {...}語法中指定了其餘插件。結果是以下構建腳本:無法將插件DSL與buildscript塊結合

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

我當時很傻。第6行的語法錯誤。在classpath之後不應該有冒號。

相關問題