搭建nexus私服部署项目

目录

1、前言

2、添加release和snapshot版本库

3、配置idea中的Maven设置

4、配置maven的settings.xml文件

5、项目中使用maven部署


1、前言

前文主要讲述了maven私服nexus的搭建:maven私服nexus搭建+mybatisplus使用-CSDN博客

本文将继续讲述搭建nexus私服有关的项目部署。

首先,需要查看nexus是否启动

2、添加release和snapshot版本库

参照链接1中的 "7.7 配置私有仓库" 的方式完成release和snapshot版本库的添加,并添加到maven-public成员中。

3、配置idea中的Maven设置

4、配置maven的settings.xml文件

自定义本地仓库位置

<localRepository>D:\Java_env\maven\resp</localRepository>

server

注意:

id: 名字不能重复,和pom引入名称相同

username/password: nexus的登录用户名密码

<server>

<id>****-repository</id>

<username>admin</username>

<password>123</password>

</server>

<server>

<id>****-releases</id>

<username>admin</username>

<password>123</password>

</server>

<server>

<id>****-snapshots</id>

<username>admin</username>

<password>123</password>

</server>

mirror

注意:url:是nexus的maven-public

<mirror>

<id>aliyunmaven</id>

<mirrorOf>*</mirrorOf>

<name>阿里云公共仓库</name>

<url>https://maven.aliyun.com/repository/public\</url>

</mirror>

<mirror>

<id>****maven</id>

<mirrorOf>*</mirrorOf>

<name>****-repository</name>

<url>https://192.168.***.***:8081/repository/maven-public/</url>

</mirror>

profile

规范jdk版本(略)

nexus仓库配置

<profile>

<!--profile 的 id-->

<id>nexus</id>

<repositories>

<repository>

<!--仓库 id,repositories 可以配置多个仓库,保证 id 不重复-->

<id>nexus</id>

<!--仓库地址,即 nexus 仓库组的地址-->

<url>http://192.168.***.***:8081/repository/maven-public/</url>

<!--是否下载 releases 构件-->

<releases>

<enabled>true</enabled>

</releases>

<!--是否下载 snapshots 构件-->

<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>

</repositories>

<pluginRepositories>

<!-- 插件仓库,maven 的运行依赖插件,也需要从私服下载插件 -->

<pluginRepository>

<!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 -->

<id>public</id>

<name>Public Repositories</name>

<url>http://192.168.***.***:8081/repository/maven-public/</url>

<!--是否下载 releases 构件-->

<releases>

<enabled>true</enabled>

</releases>

<!--是否下载 snapshots 构件-->

<snapshots>

<enabled>true</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

</profile>

activeprofile

<activeProfiles>

<activeProfile>nexus</activeProfile>

</activeProfiles>

5、项目中使用maven部署

配置pom文件

XML 复制代码
    <distributionManagement>
        <snapshotRepository>
            <id>****-snapshots</id>
            <url>http://192.168.***.***:8081/repository/****-snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>****-releases</id>
            <url>http://192.168.***.***:8081/repository/****-releases/</url>
        </repository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>nexus</id>
            <url>http://192.168.***.***:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

maven部署deploy测试结果

控制台:"BUILD SUCCESS"

nexus私服网址打开查看


感谢阅读,码字不易,多谢点赞!如有不当之处,欢迎反馈指出,感谢!

相关推荐
考虑考虑1 小时前
JDK27结构化并发
java·后端·java ee
Cosolar4 小时前
监控指标全正常,订单接口从 80ms 涨到 4s 故障复盘
java·后端·面试
会编程的吕洞宾13 小时前
Spring AI 2.0 工具调用实战:让 AI 自动调用你的 Java 方法
java·人工智能·经验分享·后端·spring
斯维赤13 小时前
SELECT * 为什么是覆盖索引的天敌?
java·后端·mysql
stormsha13 小时前
库存 5,10 个并发各买 1 件:为什么最后不剩 -5 件
java·数据库·mysql
RobinXYuan14 小时前
【Java 字节码探秘】02 ClassFile 骨架:十个字段
java·jvm·源码阅读
炸薯条!14 小时前
Python面向对象基础:类与对象、实例方法、魔法方法和属性详解
java·开发语言·python
SimonKing15 小时前
又一款数据库同步神器,2.3K Star的dbswitch
java·后端·程序员
CoderYanger15 小时前
Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式
java·数据库·hive·spring boot·面试·java-ee·mybatis
Rain的Java大神之路16 小时前
前端转 Java 全栈:用 AI 两天交付一个能跑的 Demo,踩坑全记录
java·前端·后端