yuanyeex-wiki

Yuanyeex is coding ...

Maven和Gradle设置国内镜像

2022-09-25 1 min read Development Yuanyeex

gradle全局设置国内镜像:

在${user.home}/.gradle/下创建init.gradle文件,内容如下:

allprojects {
    repositories {
        mavenLocal()
        maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" }
        maven { name "Bstek" ; url "http://nexus.bsdn.org/content/groups/public/" ; allowInsecureProtocol = true }
	    mavenCentral()
    }
 
    // buildscript {
    //     repositories {
    //         maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' }
    //         maven { name "Bstek" ; url 'http://nexus.bsdn.org/content/groups/public/'; allowInsecureProtocol = true }
    //         maven { name "M2" ; url 'https://plugins.gradle.org/m2/' }
    //     }
    // }
}

maven配置.m2目录下的配置:

cat ~/.m2/settings.xml

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">

  <mirrors>
    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>*</mirrorOf>
      <name>aliyunmaven</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
  </mirrors>

</settings>