maven私服搭建-nexus

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值