For students who often use jar packages in maven remote repository, the most troublesome thing is that after adding jar package dependency configuration, it takes a long process of downloading jar packages, because the maven repository website is a foreign website and the speed is very slow. It is too troublesome to put the good jar package locally and then load it.
In the past, there was an Oschina domestic maven image warehouse address, but it should be deprecated now (I have waited for a long time). Now, in China, it mainly uses Alibaba Cloud's maven image warehouse, which is very fast~~~
gradle configuration: replace the original mavenCentral() directly or put it in front of this (default is to search from top to bottom, so put it in front of mavenCentral. If it is added after mavenCentral, it is equivalent to not adding it)
repositories { maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'} mavenLocal() mavenCentral() }maven configuration:
<repository> <repository> <id>aliyunmaven</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </repository> </repository>
Question 2: How to use domestic mirrors
If using maven
Find settings.xml and set the source. Here we use Alibaba Cloud's source, and the speed is still quite fast.
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf></mirror>
If using gradle
Create a new file init.gradle under USER_HOME/.gradle/, enter the content below and save.
allprojects{ repositories { def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." remove repo } } } maven { url REPOSITORY_URL } }}The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.