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
   ...
}

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap