maven的nexus私服搭建配置使用

1.nexus3.x安装启动

  • 以管理员身份打开cmd,进入bin目录

    • 安装服务:nexus.exe /install
    • 启动服务:nexus.exe /start
    • 停止服务:nexus.exe /stop
    • 带控制台的启动服务:nexus.exe /run
    • 卸载服务:nexus.exe /uninstall
  • 打开浏览器,访问http://localhost:8081/

  • 登录账号admin,密码见文件,第一次登录提示修改密码

2.nexus服务器预置仓库

  • 类型介绍
    • hosted:是本地仓库,用户可以把自己的一些jar包发布到hosted中,比如公司的第二方库
    • proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。不允许用户自己上传jar包,只能从中央仓库下载
    • group:仓库组,用来合并多个hosted/proxy仓库,当你的项目希望在多个repository使用资源时就不需要多次引用了,只需要引用一个group即可
    • virtual:虚拟仓库,基本废弃了
  • 预置仓库
    • Central:该仓库代理Maven中央仓库,其策略为Release,因此只会下载和缓存中央仓库中的发布版本构件
    • Releases:这是一个策略为Release的宿主类型仓库,用来部署正式发布版本构件
    • Snapshots:这是一个策略为Snapshot的宿主类型仓库,用来部署开发版本构件
    • 3rd party:这是一个策略为Release的宿主类型仓库,用来部署无法从maven中央仓库获得的第三方发布版本构件,比如IBM或者oracle的一些jar包(比如classes12.jar),由于受到商业版权的限制,不允许在中央仓库出现,如果想让这些包在私服上进行管理,就需要第三方的仓库
    • Public Repositories:一个组合仓库

3.将项目发布到maven私服

  • maven的setting.xml配置

    xml 复制代码
    <?xml version="1.0" encoding="UTF-8"?>
    
    <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
      <!-- 本地仓库路径 -->
      <localRepository>D:\repo</localRepository>
    
      <pluginGroups>
      </pluginGroups>
    
      <proxies>
      </proxies>
    
      <servers>
        <!-- nexus私服 -->
        <server>
          <id>nexus-gen</id>
          <username>admin</username>
          <password>Gen123</password>
        </server>
      </servers>
    
      <mirrors>
        <!-- nexus镜像 -->
        <mirror>
          <id>nexus-gen</id>
          <mirrorOf>*</mirrorOf>
          <name>maven-public</name>
          <url>http://localhost:8081/repository/maven-public/</url>
        </mirror>
      </mirrors>
    
      <profiles>
        <profile>
          <id>gen</id>
          <repositories>
            <repository>
              <id>nexus-gen</id>
              <name>maven-public</name>
              <url>http://localhost:8081/repository/maven-public/</url>
              <releases>
                <enabled>true</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
              </snapshots>
            </repository>
          </repositories>
        </profile>
      </profiles>
    
      <activeProfiles>
        <activeProfile>gen</activeProfile>
      </activeProfiles>
    </settings>
  • 项目中pom.xml配置

    xml 复制代码
    <distributionManagement>
        <repository>
            <id>nexus-gen</id>
            <name>gen</name>
            <url>http://localhost:8081/repository/gen/</url>
        </repository>
    </distributionManagement>
  • 然后在项目中clean deploy即可

相关推荐
muxin-始终如一8 小时前
Maven HTTP 仓库被阻止问题解决总结
java·http·maven
计算机毕设指导69 小时前
基于微信小程序的扶贫助农系统【源码文末联系】
java·spring boot·后端·微信小程序·小程序·tomcat·maven
絔宝10 小时前
Eclipse配置 Maven 国内镜像
java·eclipse·maven
jasnet_u12 小时前
nexus3私服使用及setting.xml配置
maven·nexus
CryptoRzz13 小时前
印度交易所 BSE 与 NSE 实时数据 API 接入指南
java·c语言·python·区块链·php·maven·symfony
南屿欣风14 小时前
Maven 聚合工程打包报错:Unable to find main class 快速解决
java·maven
_loehuang_14 小时前
Docker Compose 部署 Maven 私有库 nexus3
java·docker·maven·nexus·maven私有库
IT 行者1 天前
从 Gitee 开源项目发布到 Maven Central 中央仓库完整指南
gitee·开源·maven·中央仓库
0xwang2 天前
maven scope引起的程序崩溃
java·maven
计算机毕设指导62 天前
基于微信小程序的家政服务与互助平台【源码文末联系】
java·spring boot·mysql·微信小程序·小程序·tomcat·maven