各种源
替换命令:sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
Gradle
在项目中配置
build.gradle 文件中加入以下代码:
repositories {
maven { url 'https://maven.aliyun.com/repository/public/' }
mavenCentral()
}
settings.gradle 文件第一行:
pluginManagement {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
gradlePluginPortal()
}
}
配置文件配置
init.gradle.kts
fun RepositoryHandler.enableMirror() {
all {
if (this is MavenArtifactRepository) {
val originalUrl = this.url.toString().removeSuffix("/")
urlMappings[originalUrl]?.let {
logger.lifecycle("Repository[$url] is mirrored to $it")
this.setUrl(it)
}
}
}
}
val urlMappings = mapOf(
"https://repo.maven.apache.org/maven2" to "https://maven.aliyun.com/repository/public/",
"https://plugins.gradle.org/m2" to "https://maven.aliyun.com/repository/public/"
)
gradle.allprojects {
buildscript {
repositories.enableMirror()
}
repositories.enableMirror()
}
gradle.beforeSettings {
pluginManagement.repositories.enableMirror()
dependencyResolutionManagement.repositories.enableMirror()
}
android studio 参考配置
gradle-wrapper.properties中的下载地址:
https://mirrors.aliyun.com/gradle/distributions/
Maven
settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository />
<interactiveMode />
<offline />
<pluginGroups />
<servers />
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public </url>
</mirror>
</mirrors>
<proxies />
<profiles />
<activeProfiles />
</settings>
Go
Go 1.13 及以上(推荐)
go env -w GOPROXY=https://goproxy.cn,direct
NPM
npm config set registry https://registry.npmmirror.com
electron
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ npm install -g electron
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/ electron-builder build
或者在.npmrc
中添加
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
pip
#设为默认
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
# 临时使用
pip install -i https://mirrors.cloud.tencent.com/pypi/simple <some-package>
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
pip install -i https://mirrors.aliyun.com/pypi/simple some-package
pip.conf
文件中:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/ # 根据需要选清华源或者阿里源
[install]
trusted-host=mirrors.aliyun.com
Docker
参考这个:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.1panel.live",
"https://docker.xuanyuan.me",
"https://dockerproxy.net",
"https://image.cloudlayer.icu",
"https://docker-registry.nmqu.com",
"https://hub.amingg.com",
"https://docker.amingg.com",
"https://docker.hlmirror.com",
"https://hub3.nat.tf"
]
}
EOF