2015-11-06 72 views
5

我有以下項目結構:插件ID爲春季啓動在父母的build.gradle沒有發現

的Java/
   的build.gradle
    settings.gradle
   了projectA/
        build.gradle
    projectB/
       的build.gradle

當我把下面碼,例如了projectA的的build.gradle,

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

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'spring-boot' 
... 

一切工作正常。

但是如果我把上面的代碼Java的的build.gradle:

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

    apply plugin: 'java' 
    apply plugin: 'eclipse' 
    apply plugin: 'spring-boot' 
    ... 
} 

運行時的gradle乾淨的構建,它使報告如下錯誤:

Plugin with id 'spring-boot' not found.

任何人都遇到過這個問題?爲什麼?

回答

7

我想出了一個解決方案,但不知道爲什麼。會花了一些時間在週末閱讀文檔...

變化多項目的build.gradle以下:

buildscript { 
    repositories { 
     mavenCentral() 
    } 

    dependencies { 
      classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE") 
    } 
} 

subprojects { 
    apply plugin: 'java' 
    apply plugin: 'eclipse' 
    apply plugin: 'spring-boot' 
    ... 
} 

即移動buildscript出子項目