一、Homebrew的镜像设置
对于Java JDK的安装,我们更推荐使用Homebrew来进行安装管理。但Homebrew的curl国外源的下载速度实在是一言难尽,时常还会发生无法访问的情况。
那么我们此时的解决方法就有两种了,第一种便是使用全局的VPN代理进行下载,其次就是更为推荐的方法:使用国内镜像下载。熟悉NPM、MAVEN等工具的同学们应该对更换镜像源这个操作都是比较熟悉的。
1. 镜像替换
那么首先是对镜像进行替换的脚本如下:
# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
当不需要再使用镜像源或镜像源损坏无法安装时,我们便需要还原镜像源,还原的脚本如下:
# 还原brew.git
cd