1. 安装包
window:版本
https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.37.3-02-win64.zip
linux:版本
https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.37.3-02-unix.tar.gz
2.相关脚本
<!-- 启动仓库服务 -->
bin/nexus run
<!-- 停止仓库服务,使用kill -9 命令 -->
<!-- 启动web服务-->
bin/nexus start
<!-- 停止web服务-->
bin/nexus stop
<!-- 访问程序网址: http://ip:端口(默认8081)/nextus(配置文件中配置,参照下图) -->
http://192.168.236.69:8081/nexus/
默认用户名:admin
密码:根据登录页面提示的文件中查找
创建仓库:
参照网页:
https://blog.csdn.net/u014756339/article/details/106808447
创建用户:在maven配置文件中配置的是用户id和密码
创建角色:
maven配置:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/myMaven/mavenSF</localRepository>
<servers>
<server>
<id>xwk-releases</id>
<username>deployment</username>
<password>deployment</password>
</server>
<server>
<id>xwk-snapshot</id>
<username>deployment</username>
<password>deployment</password>
</server>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>nexus</id>
<mirrorOf>*,!jeecg,!jeecg-snapshots</mirrorOf>
<name>nexus repository</name>
<url>http://192.168.236.60:8081/nexus/repository/shenxi-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://192.168.236.60:8081/nexus/repository/shenxi-public/</url>
<releases>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</releases>
<snapshots>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://192.168.236.60:8081/nexus/repository/shenxi-public/</url>
<releases>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</releases>
<snapshots>
<enabled>
true
</enabled>
<updatePolicy>
always
</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
pom配置:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>test-mav</artifactId>
<version>1.0-RELEASE</version>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.79</version>
</dependency>
</dependencies>
<!-- 发布 -->
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>nexus</id>
<url>http://192.168.236.60:8081/nexus/repository/shenxi-public/</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<!-- id一定要和maven setting中的配置一样 -->
<id>shenxi-releases</id>
<url>http://192.168.236.60:8081/nexus/repository/xwk-hosted/</url>
</repository>
<snapshotRepository>
<id>shenxi-snapshot</id>
<url>http://192.168.236.60:8081/nexus/repository/xwk-hosted/</url>
</snapshotRepository>
</distributionManagement>
</project>
单个上传包:
批量上传:
<!--参照此网页:-->
https://blog.csdn.net/lihbps/article/details/104527652
#!/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}/{} ;
./mavenimport.sh -u admin -p tmkj@zgb123 -r http://192.168.236.60:8081/nexus/repository/xwk-hosted