When I'm trying to clean my project with ./gradlew clean
it works, but
the ./gradlew build
won't work. I tried a few repositories, but it can't resolve the Spring dependencies.
Here is the 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()
}
And here the exception:
* 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
I thought the maven repo is enough but it keeps failing I also tried it with jcenter()
. Im working on a ubuntu 14.04 VM.
SOLVED:
As Michael said in the comments I had to add a version for the dependency:
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE')
First, declare repositories before dependencies. And second, replace
compile('org.springframework.boot:spring-boot-starter-web')
with
compile('org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE')
because the former doesn't contain a version.