How to add maven central repository in build.gradle

In order to add the Maven Central Repository to your Java project, all you need to do is add the below to the repositories block of the build.gradle file.


repositories {
    mavenCentral()
}

Note: Make sure to add this repository block outside of any other dependencies or plugins.


Example:
plugins {
   ...
   //plugins
   ...
}

repositories {
    mavenCentral()
}

dependencies {
   ...
   //project dependencies
   ...
}

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!