本地maven setting.xml
</servers>
<server>
<id>geovis</id>
<username>admin</username>
<password>icenter123</password>
</server>
<server>
<id>releases</id>
<username>admin</username>
<password>icenter123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>icenter123</password>
</server>
</servers>
项目pom
<!-- 使用分发管理将本项目打成jar包,直接上传到指定服务器 -->
<distributionManagement>
<repository>
<!-- nexus服务器中用户名:在settings.xml中<server>的id-->
<id>releases</id>
<!-- 这个名称自己定义 -->
<name>Releases</name>
<url>http://192.168.71.62:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>
提交命令
# -e 为打印日志,打印更详细日志可用 -X
mvn clean deploy -e
将单个依赖提交到nexus,DrepositoryId对应账号密码,账号密码配置与上方一样
将多个依赖提交到nexus
在nexus上新建一个respository,将新包上传到这个respository上,防止意外
在公网上将项目依赖拉到本地电脑的 respository,将此目录打包并上传到服务器上,再解压到respository,进入repository
vi mavenimport.sh
#!/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
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 './mavenimport\.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}/{} ;
chmod a+x mavenimport.sh
启动脚本
./mavenimport.sh -u admin -p icenter123 -r http://192.168.21.62:8081/repository/maven-upgrade/
将nexus上新建的respository,关联并应用