系统:Deepin V20
平台:amd64
asdf-vm
安装asdf-vm
安装java
asdf-java
代码asdf plugin add java https://github.com/halcyon/asdf-java.git
.tsv
文件地址vim ~/.asdf/plugins/java/bin/functions
找到以下内容
if [[ ! -r "${cache_file}" ]] || (( $($STAT "${STAT_OPTS[@]}" "${cache_file}") <= $(date +%s) - 3600 )) ; then
curl -s -f --compressed -L "https://raw.githubusercontent.com/halcyon/asdf-java/master/data/jdk-${OS}-${ARCHITECTURE}.tsv" -o "${cache_file}"
fi
替换为
if [[ ! -r "${cache_file}" ]] || (( $($STAT "${STAT_OPTS[@]}" "${cache_file}") <= $(date +%s) - 3600 )) ; then
cp "${HOME}/.asdf/plugins/java/data//jdk-${OS}-${ARCHITECTURE}.tsv" "${cache_file}"
fi
adoptopenjdk-8.0.181+13
asdf install java adoptopenjdk-8.0.181+13
java
版本asdf global java adoptopenjdk-8.0.181+13
在项目目录下创建.tool-versions
文件,在文件中添加以下内容
java adoptopenjdk-8.0.181+13
然后在项目目录下执行以下命令查看效果
java -version
输出如下信息
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.181-b13, mixed mode)
grep: /tmp/asdf-java.cache/releases.tsv: 没有那个文件或目录
产生原因:因为国内无法访问https://raw.githubusercontent.com
地址导致。
解决办法:
编辑~/.asdf/plugins/java/bin/functions
文件
找到以下内容
if [[ ! -r "${cache_file}" ]] || (( $($STAT "${STAT_OPTS[@]}" "${cache_file}") <= $(date +%s) - 3600 )) ; then
curl -s -f --compressed -L "https://raw.githubusercontent.com/halcyon/asdf-java/master/data/jdk-${OS}-${ARCHITECTURE}.tsv" -o "${cache_file}"
fi
替换为
if [[ ! -r "${cache_file}" ]] || (( $($STAT "${STAT_OPTS[@]}" "${cache_file}") <= $(date +%s) - 3600 )) ; then
cp "~/.asdf-java/master/data/jdk-${OS}-${ARCHITECTURE}.tsv" "${cache_file}"
fi