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

相关推荐
甄超锋14 小时前
Java Maven更换国内源
java·开发语言·spring boot·spring·spring cloud·tomcat·maven
还是鼠鼠15 小时前
tlias智能学习辅助系统--Maven 高级-私服介绍与资源上传下载
java·spring boot·后端·spring·maven
小小工匠2 天前
Maven - Spring Boot 项目打包本地 jar 的 3 种方法
spring boot·maven·jar·system scope
期待のcode2 天前
Maven
java·spring·maven·mybatis
是小崔啊3 天前
【Maven】03 - 私服搭建
java·maven
邦杠4 天前
最新SpringBoot上传Maven中央仓库,在其他项目直接引入依赖(github开源项目打包上传,不需要私服)
spring boot·后端·开源·github·maven
THXW.5 天前
【Java项目与数据库、Maven的关系详解】
java·数据库·maven
匚WYHaovous6 天前
Maven项目JAR定位
maven
熊猫片沃子7 天前
Maven在使用过程中的核心知识点总结
java·后端·maven
草履虫建模8 天前
RuoYi-Cloud 微服务本地部署详细流程实录(IDEA + 本地 Windows 环境)
java·spring boot·spring cloud·微服务·云原生·架构·maven