1. nexus 3.25版本maven仓库,同步依赖
上传本地依赖仓库压缩包至服务器,Linux 服务器新建sh脚本,内容填充以下内容,脚本位置在解压依赖的目录下,与各种依赖包同级。
运行命令: ./nexusImport.sh -u admin -p admin123 -r http://xxxxx:8280/repository/self-repo/
```java
#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
#运行指令 依赖同级文件夹下运行 ./nexusImport.sh -u admin -p admin123 -r http://xxxxx:8280/repository/self-repo/
while getopts ":r:u:p:" opt; do
case $opt in
r) REPO_URL="$OPTARG"
;;
u) USERNAME="$OPTARG"
;;
p) PASSWORD="$OPTARG"
;;
esac
done
find . -type f -not -path './mavenUpload\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
```
2. 远端仓库没有相关依赖,本地仓库导入了相关依赖,构建项目报错。
远端仓库没有某个依赖,本地仓库实质已经存在,工程内部都没报错,但是install构建打包时,总是去尝试从远端获取,然后报错,无法构建。
解决方法:找到本地仓库依赖目录,去掉_remote.repositories文件。
_remote.repositories标记当前依赖变动,或者仓库变动时会从远端进行下载,如果下载不到,那么会抛出错误,因此,本机仓库已有了这个依赖,远端暂时不想上传的话,可以先删掉这个文件,跳过远端获取的步骤。