使用Nexus搭建Maven私服

使用Nexus搭建Maven私服

  1. 使用Nexus版本为nexus-2.12.0-01-bundle.zip
    链接:https://pan.baidu.com/s/1VlL-qLiZ7u2JSGLyFlXhZA
    提取码:6yfn

  2. 将压缩包解压到任意非中文目录中
    在这里插入图片描述

  3. 根据电脑型号选择相应的批处理文件安装开启Nexus私服。如我的电脑是Win64故选择D:\nexus\nexus-2.12.0-01\bin\jsw\windows-x86-64目录下的批处理文件。
    在这里插入图片描述
    install-nexus.bat:安装私服
    start-nexus.bat:运行私服
    stop-nexus.bat:关闭私服
    uninstall-nexus.bat:卸载私服
    注意:若提示以下错误,以管理员权限运行文件即可
    在这里插入图片描述

  4. 启动后默认端口为8081,可在浏览器查看,显示此页面代表安装成功。
    在这里插入图片描述

  5. 可点击右上方的log in登录,默认
    用户名:admin
    密码:admin123

  6. 此时未配置索引则不可进行搜索服务,下面搜索框无效果
    在这里插入图片描述
    最简单的下载索引:把此位置false改为true即可
    在这里插入图片描述
    下载完成后即可实现搜索功能,如下所示
    在这里插入图片描述
    到这里Maven私服即搭建完毕!

  7. 使用Maven连接私服
    首先下载Maven并搭建好Maven环境引用setting.xml
    配置setting.xml
    7.1 本地仓库路径

    copy
    <localRepository>D:/Maven/repository</localRepository>

    7.2 配置jdk

    copy
    <profile>
    <id>jdk-1.8</id>
    <activation>
    <activeByDefault>true</activeByDefault>
    <jdk>1.8</jdk>
    </activation>
    <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>
    </profile>

    7.3 配置私服构建(连接私服用的到jar等内容)

    copy
    <profile>
    <id>nexusTest</id>
    <repositories>
    <repository>
    <id>local-nexus</id>
    <url>http://127.0.0.1:8091/nexus/content/groups/public/</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </repository>
    </repositories>
    </profile>

    7.4 配置让私服构建生效(nexusTest为上面的)

    copy
    <activeProfiles> <!--激活id为nexusTest的profile-->
    <activeProfile>nexusTest</activeProfile>
    </activeProfiles>

    7.5 配置镜像Maven连接私服

    copy
    <mirror>
    <id>nexus-releases</id>
    <mirrorOf>*</mirrorOf>
    <url>http://localhost:8091/nexus/content/groups/public</url>
    </mirror>
    <mirror>
    <id>nexus-snapshots</id>
    <mirrorOf>*</mirrorOf>
    <url>http://localhost:8091/nexus/content/repositories/apache-snapshots/</url>
    </mirror>
  8. 把项目发布到私服上步骤
    8.1 在Maven项目pom.xml中配置私服路径

    copy
    <distributionManagement>
    <repository>
    <id>releases</id>
    <url>http://localhost:8091/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
    <id>snapshots</id>
    <url>http://localhost:8091/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
    </distributionManagement>

    8.2 在setting.xml中配置连接私服仓库的用户名和密码

    copy
    **<server><id>和pom.xml中<repository><id>对应**
    copy
    <server>
    <id>releases</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    <server>
    <id>snapshots</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    </servers>

    8.3 执行Maven的deploy命令即可发布项目到私服
    项目默认为SNAPSHOT版本,可自行更换在这里插入图片描述

  9. 从私服获取项目直接添加依赖即可。

这就是Maven搭建私服及使用的过程了,一起开始快乐的编码吧,哈哈哈!

posted @   FireCode  阅读(156)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示
🚀