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 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配置

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

  • 27
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水宝的滚动歌词

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值