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>
相关推荐
Byron Loong12 分钟前
【c++】为什么有了dll和.h,还需要包含lib
java·开发语言·c++
hexu_blog44 分钟前
vue+java实现图片批量压缩
java·前端·vue.js
头歌实践平台1 小时前
Hadoop开发环境搭建
java·大数据·hadoop
Seven971 小时前
一致性Hash算法:如何实现分布式系统中的高效数据分片?
java
摇滚侠1 小时前
IDEA 生成 try catch 快捷键
java·ide·intellij-idea
阿旭超级学得完2 小时前
C++11包装器(function和bind)
java·开发语言·c++·算法·哈希算法·散列表
掉鱼的猫3 小时前
Spring AI 2.0 GA 倒计时:先别急,来看看 Java AI 框架的另一条路
java·openai·agent
Refrain_zc3 小时前
Android 应用内 APK 安装全方案:从静默安装到普通安装的详解
java
正儿八经的少年3 小时前
Spring Boot 两种激活配置方式的作用与区别
java·spring boot·后端