2016-04-14 90 views
0

當我試圖用./gradlew clean來清理我的項目時,它可以工作,但 ./gradlew build不起作用。我嘗試了一些存儲庫,但它無法解決Spring依賴關係。Gradlew構建不起作用

這裏是build.gradle

apply plugin: 'war' 

war { 
    baseName = 'hello' 
} 

configurations { 
    providedRuntime 
} 

dependencies { 

    compile('org.springframework.boot:spring-boot-starter-web') 
    compile('org.json:json:20141113') 
    compile('com.jayway.jsonpath:json-path:0.8.1') 
    compile('org.jsoup:jsoup:1.8.2') 
    compile('org.springframework.social:spring-social-twitter') 
    compile('org.springframework.social:spring-social-twitter:1.1.0.RELEASE') 
    compile('org.springframework.social:spring-social-core') 
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat') 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

repositories { 
     mavenCentral() 
} 

這裏的例外:

* What went wrong: 
Could not resolve all dependencies for configuration ':compile'. 
> Cannot resolve external dependency org.springframework.boot:spring-boot-starter-web: because no repositories are defined. 
    Required by: 
     :hello:unspecified 
> Cannot resolve external dependency org.json:json:20141113 because no repositories are defined. 
    Required by: 
     :hello:unspecified 
> Cannot resolve external dependency com.jayway.jsonpath:json-path:0.8.1 because no repositories are defined. 
    Required by: 
     :hello:unspecified 
> Cannot resolve external dependency org.jsoup:jsoup:1.8.2 because no repositories are defined. 
    Required by: 
     :hello:unspecified 
> Cannot resolve external dependency org.springframework.social:spring-social-twitter:1.1.0.RELEASE because no repositories are defined. 
    Required by: 
     :hello:unspecified 
> Cannot resolve external dependency org.springframework.social:spring-social-twitter:1.1.0.RELEASE because no repositories are defined. 
    Required by: 
     :hello:unspecified 
> Cannot resolve external dependency org.springframework.social:spring-social-core: because no repositories are defined. 
    Required by: 
     :hello:unspecified 

我認爲Maven的回購協議是不夠好,但它一直未能我也jcenter()試了一下。我工作在一個Ubuntu 14.04虛擬機。

解決:

正如邁克爾在我不得不添加一個版本的依賴評論說:

compile('org.springframework.boot:spring-boot-starter-web') 
compile('org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE') 
+0

您是否嘗試過在依賴關係之前聲明存儲庫? – Michael

+0

是這個例外:'找不到org.springframework.boot:spring-boot-starter-web' – julien

+0

我確定你需要應用spring-boot Gradle插件來管理依賴關係才能工作。有關詳細信息,請參閱任何Spring Boot Gradle示例。 – cjstehno

回答

1

首先,依賴前申報資料庫。其次,與

compile('org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE') 

更換

compile('org.springframework.boot:spring-boot-starter-web') 

,因爲前者不包含版本。