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即可

相关推荐
叶 落20 小时前
[Maven 基础课程]再看下第一个 Maven 项目
maven·maven 入门·maven 基础课程
开开心心_Every1 天前
免费语音合成工具:66种音色随心选
人工智能·面试·java-ee·计算机外设·电脑·maven·excel
wangmengxxw2 天前
Maven的介绍及基本使用
java·maven
坚持每天敲代码2 天前
【教程】IDEA中导入springboot-maven工程
java·maven·intellij-idea
祈祷苍天赐我java之术2 天前
Maven 从入门到精通
java·maven
令狐少侠20112 天前
maven settings.xml文件的各个模块、含义以及它们之间的联系
xml·maven
栗子~~3 天前
bat脚本- 将jar 包批量安装到 Maven 本地仓库
java·maven·jar
Mr.Entropy3 天前
ecplise配置maven插件
java·maven
华农第一蒟蒻5 天前
Elasticsearch赋能3D打印机任务统计分析
java·大数据·spring boot·后端·elasticsearch·adb·maven
zhong liu bin5 天前
maven【maven】技术详解
java·ide·python·spring·maven·intellij-idea