行业资讯 2025年08月6日
0 收藏 0 点赞 1,003 浏览 3918 个字
摘要 :

文章目录 Nexus快速入门、安装 一、下载 二、搭建服务 1、解压 2、安装 3、运行 4、修改端口 5、登录 三、配置私服 1、配置仓库 2、创建阿里云代理仓库 4、 设置阿里……




  • Nexus快速入门、安装
  • 一、下载
  • 二、搭建服务
    • 1、解压
    • 2、安装
    • 3、运行
    • 4、修改端口
    • 5、登录
  • 三、配置私服
    • 1、配置仓库
    • 2、创建阿里云代理仓库
    • 4、 设置阿里云镜像优先
  • 四、在Maven中使用私服
    • 1、设置maven conf下的setting.xml文件。
    • 2、上传jar包
    • 3、往私有仓发布自编jar包

    Nexus快速入门、安装

    在公司开发测试过程中,内网团队使用一个服务来节省外网宽带以及缓存Maven Respository中没有的jar包,允许上传和下载私有库,并且不被外部访问,安全稳定

    一、下载

    官网下载地址,但是速度很慢,可以使用csdn资源链接获取

    二、搭建服务

    1、解压

    解压好下载的nexus压缩包,会有以下两个文件:nexus-3.42.0-01和sonatype-work

    2、安装

    右键开始菜单打开管理员cmd,进入到nexus-3.42.0-01\\bin目录下,执行:

    .\\nexus.exe /install nexus
    

    将其安装到Windows服务中(因为已经安装过服务,所以再次执行会出现 “已安装”的提示)

    windows搭建Nexus Maven私有仓库图文教程

    3、运行

    使用nexus.exe /start nexus.exe /stop 进行开启和关闭服务。或者执行nexus.exe /run来通过命令窗口方式执行。 (第一次启动会花费较长时间)
    启动成功后,默认端口为8081,浏览器访问方式为:localhost:8081

    4、修改端口

    修改端口可以编辑nexus-3.42.0-01\\etc\\nexus-default.properties下的application-port属性

    windows搭建Nexus Maven私有仓库图文教程

    windows搭建Nexus Maven私有仓库图文教程

    5、登录

    点击右上角Sign in进行登录,默认用户名是admin,密码会随机生成在nexus\\sonatype-work\\nexus3下的password文件中,登录后即可修改密码。

    windows搭建Nexus Maven私有仓库图文教程

    三、配置私服

    1、配置仓库

    登录之后菜单栏左侧会有一个设置的图标,点击后再点Repositories进行配置仓库

    1)maven-central,maven中央库,默认从https://repo1.maven.org/maven2/拉取jar (下载速度很慢,这就是下面一步创建阿里云代理的原因);
    2)maven-releases:私库打包发行版jar;(可上传自编jar包)
    3)maven-snapshots:私库快照版jar;(可上传自编jar包)
    4)maven-public:仓库分组,把上面三个仓库组合在一起后对外提供服务,在本地maven setting.xml中配置;

    windows搭建Nexus Maven私有仓库图文教程

    2、创建阿里云代理仓库

    点击Create repositories创建一个阿里云代理仓库 (跟在maven => Setting.xml更改阿里云镜像道理一样)
    1)proxy:提供代理其它仓库的类型;
    2)hosted:本地存储。像官方仓库一样提供本地私库功能;
    3)group:组类型,能够组合多个仓库为一个地址提供服务;

    windows搭建Nexus Maven私有仓库图文教程 windows搭建Nexus Maven私有仓库图文教程

    阿里云镜像服务URL详见:仓库服务
    点击最下方Create Repositories按钮创建完毕

    4、 设置阿里云镜像优先

    点击maven-public 设置阿里云镜像优先使用

    windows搭建Nexus Maven私有仓库图文教程 windows搭建Nexus Maven私有仓库图文教程

    四、在Maven中使用私服

    1、设置maven conf下的setting.xml文件。

    公司的小伙伴需共同将本地的setting.xml指向公司的nexus私有仓

    <?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>E:\\maven\\mavenLocal</localRepository> <!-- 配置jar包存放位置 -->
        <mirrors>
       
         <!-- 配置本地仓库资源来源 -->
        <mirror>
            <id>maven-public</id>
            <mirrorOf>*</mirrorOf>
            <url>http://localhost:8081/repository/maven-public/</url>
        </mirror>
      </mirrors>
        <servers>
        <!-- 配置本地仓库访问私服的权限  nexus的 登录用户名密码 -->
        <server>
            <id>maven-releases</id>
            <username>admin</username>
            <password>123456</password>
        </server>
        <server>
            <id>maven-snapshots</id>
            <username>admin</username>
            <password>123456</password>
        </server>
      </servers>
      
          <!-- 属性列表配置 -->
        <profiles>
          <profile>
            <id>my-profile</id>
            <properties>
              <maven.compiler.source>1.8</maven.compiler.source>  
              <maven.compiler.target>1.8</maven.compiler.target>  
              <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
            <!-- 远程仓库列表 maven用来填充构建系统本地仓库所使用的一组远程仓库 -->
            <repositories>
              <repository>
                <id>maven-releases</id>
                <url>http://localhost:8081/repository/maven-releases/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
              </repository>
     
              <repository>
                <id>maven-snapshots</id>
                <url>http://localhost:8081/repository/maven-snapshots/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
              </repository>
          </repositories>
     
        <pluginRepositories>
          <pluginRepository>
            <id>maven-public</id>
            <url>http://localhost:8081/repository/maven-public</url>
          </pluginRepository>
        </pluginRepositories>
        
        </profile>
      </profiles>
        <activeProfiles>
       <activeProfile>my-profile</activeProfile>     
      </activeProfiles>
    </settings>
    
    
    

    2、上传jar包

    往私有仓上传maven官方镜像中下载不到的jar包

    windows搭建Nexus Maven私有仓库图文教程 windows搭建Nexus Maven私有仓库图文教程

    3、往私有仓发布自编jar包

    1)可使用第二步打包后手动上传
    2)在需发布的项目pom文件中添加 distributionManagement配置,而后使用 idea 工具右侧的maven栏,点击 deploy 发布到远程仓库,而后登陆到你的nexus私服即可查看部署的jar包
    package:完成了项目编译、单元测试、打包功能,但并没有把打好的可执行jar包(war包或其它形式的包)布署到本地maven仓库和远程maven私服仓库
    install: 完成了项目编译、单元测试、打包功能,同时把打好的可执行jar包(war包或其它形式的包)布署到本地maven仓3库,但没有布署到远程maven私服仓库
    deploy:完成了项目编译、单元测试、打包功能,同时把打好的可执行jar包(war包或其它形式的包)布署到本地maven仓库和远程maven私服仓库

    <!--  maven仓库配置 deploy时可推送到对应的配置仓库中    -->
        <distributionManagement>
            <repository>
                <id>maven-releases</id>
                <name>Nexus Releases Repository Pro</name>
                <url>http://localhost:8081/repository/maven-releases/</url> <!--  正式版推送到这    -->
            </repository>
     
            <snapshotRepository>
                <id>maven-snapshots</id>
                <name>Nexus Snapshots Repository Pro</name>
                <url>http://localhost:8081/repository/maven-snapshots/</url> <!--  测试版推送到这    -->
            </snapshotRepository>
        </distributionManagement>
    
    

    windows搭建Nexus Maven私有仓库图文教程

    以上就是windows搭建Nexus Maven私有仓库图文教程的全部内容,欢迎留言评论。

微信扫一扫

支付宝扫一扫

版权: 转载请注明出处:https://www.zuozi.net/8821.html

管理员

相关推荐
2025-08-06

文章目录 一、Reader 接口概述 1.1 什么是 Reader 接口? 1.2 Reader 与 InputStream 的区别 1.3 …

985
2025-08-06

文章目录 一、事件溯源 (一)核心概念 (二)Kafka与Golang的优势 (三)完整代码实现 二、命令…

463
2025-08-06

文章目录 一、证明GC期间执行native函数的线程仍在运行 二、native线程操作Java对象的影响及处理方…

347
2025-08-06

文章目录 一、事务基础概念 二、MyBatis事务管理机制 (一)JDBC原生事务管理(JdbcTransaction)…

455
2025-08-06

文章目录 一、SnowFlake算法核心原理 二、SnowFlake算法工作流程详解 三、SnowFlake算法的Java代码…

515
2025-08-06

文章目录 一、本地Jar包的加载操作 二、本地Class的加载方法 三、远程Jar包的加载方式 你知道Groo…

831
发表评论
暂无评论

还没有评论呢,快来抢沙发~

助力内容变现

将您的收入提升到一个新的水平

点击联系客服

在线时间:08:00-23:00

客服QQ

122325244

客服电话

400-888-8888

客服邮箱

122325244@qq.com

扫描二维码

关注微信客服号