Nexus私服的使用(配合Maven)

1.Nexus安装、配置、基本使用

下载地址:++++https://help.sonatype.com/repomanager3/product-information/download++++

1.1文件结构

下载解压后的文件结构是这样的:

1.2启动Nexus

进入nexus->bin目录下,打开cmd,执行:

复制代码
nexus  /run nexus_server (服务器名称)

开启后出现Started Sonatype Nexus OSS 3.31.1-01后就说明启动成功了,我们只需要访问一下++++http://localhost:8081/++++就查看我们的私服了;


如果要修改 8081 默认端口,到nexus->etc-> .properties文件修改端口

如果想修改虚拟机的参数,到nexus->bin->nexus.vmoptions进行修改

1.3登录

点击右上角的signIn,用户名是admin,我们第一次登录的密码是在sonatype-work\nexus3\admin.password文件下,复制粘贴即可,登录成功后他会让你设置新密码

2.仓库

2.1仓库类型

代理仓库:代理远程仓库,访问全球中央仓库或其他公共仓库,将资源存储在私服上;

宿主仓库:公司自主研发的或自主上传的资源构成的仓库,因为有闭源项目的存在,因此可以分为release和snapshot等;

仓库组:仓库组中包含多个仓库,本身就不能存资源,简化配置,配置好仓库后,避免用户自己去查找每个仓库

2.2创建仓库

创建一个存放release版本的仓库

将创建好的仓库放在仓库组中,以暴露给外界;

3.向私服仓库上传资源

3.1手工上传第三方资源

以上传oracle提供的ojdbc资源为例:

配置完了之后是这样的

3.2idea操纵nexus私服

首先我们需要配置一下本地仓库

访问私服的账号和密码在maven下conf->settings.xml下的servers中配置

复制代码
<server>
    <id>maven-public</id>
    <username>admin</username>
    <password>123456</password>
</server>

下载的地址在profiles标签下进行配置,这里url就是在私服中的仓库就可以获取

XML 复制代码
<profile>
    <id>nexus</id>
    <repositories>
        <repository>
            <id>maven-public</id>
            <name>xzit-nexus</name>
            <url>http://localhost:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>maven-public</id>
            <url>http://localhost:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</profile>

配置当前被激活的profiles

XML 复制代码
<activeProfiles>
      <activeProfile>nexus</activeProfile>
</activeProfiles>

以上在settings.xml中的配置可以让我们从私服上获取依赖或插件

以下配置可以让我们在项目中通过声明周期中的deploy上传的仓库中

在工程中配置的上传的地址在工程的pom.xml文件中做配置

XML 复制代码
<distributionManagement>
    <repository>
        <id>maven-public</id>
        <url>http://localhost:8081/repository/xzit-release/</url>
    </repository>
    <snapshotRepository>
        <id>maven-public</id>
        <url>http://localhost:8081/repository/xzit-snapshot/</url>
    </snapshotRepository>
</distributionManagement>
相关推荐
范什么特西1 分钟前
亲和路由(inspect)
java
她说可以呀4 分钟前
Docker 镜像的两种创建方式
java·分布式·docker
霸道流氓气质13 分钟前
AgentFlow 入门与实战:Task-Based 并发、EWMA 动态调度与四道门禁的 Java 生产级编排
java·开发语言
愿得一猪蹄24 分钟前
# Java线程池实战,别再new Thread了
java
ee又momo33 分钟前
# 深入理解Java注解,从使用到自定义
java
霸道流氓气质1 小时前
AI智能博客平台实战:RAG增强写作、多Agent协作与语义检索的Vue3 + Spring AI全栈实现
java·人工智能·spring
打工仔折腾 AI1 小时前
LangChain 工具调用实战:从 Tool 定义到 Agent 执行链路拆解
java·前端·人工智能·后端·python·langchain·ai agent 实战
哦虎!1 小时前
【JavaEE】网络原理 - TCP/IP
java
东风微鸣1 小时前
把 Tailscale 接进 Prometheus 监控
java·数据库·prometheus
看浪的路人1 小时前
第9讲:大模型应用监控与可观测性——OpenTelemetry + Prometheus + Grafana 全链路追踪
java·前端·spring