To study Gradle I am using the book Gradle in action. There was an example of dependency definition.

dependencies {
      compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
} 

But when I do in console gradle build I've got an error enter image description here

What is the problem? My whole .gradle file looks like this

apply plugin: 'java'

dependencies {
     compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'
}
有帮助吗?

解决方案

You did not tell Gradle where to find commons-lang3 library. Easy fix is to add the following to your build script:

repositories {
    mavenCentral()
}

Of course you can find this piece of information in documentation - http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html#N10608

其他提示

I was facing this same issue. I fixed it by using local gradle distribution instead of the default gradle wrapper. This is how it goes, make sure that you have Gradle installed and setup(PATH variable).

Open IntelliJ. Goto File->setting->Build, Exec, Deployment->Build tools->Gradle and use local gradle distribution and add your Gradle Home. Apply changes and try to run it now.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top