nexus操作

本文详细介绍Nexus私服的安装步骤、配置方法及如何通过Maven上传和下载依赖。涵盖端口配置、防火墙设置、Maven配置及POM文件调整,确保私有库高效运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装nexus
tar -zxvf xxxxxxx.tg
ls
nexus-2.11.2-03
sonatype-work
(一个 nexus 服务,一个私有库目录)
编辑 Nexus 的 nexus.properties 文件,配置端口和 work 目录信息(保留默认)
[root@localhost nexus]# cd nexus-2.11.2-03
[root@localhost nexus-2.11.2-03]# ls
bin conf lib LICENSE.txt logs nexus NOTICE.txt tmp
查看目录结构,jetty 运行
[root@localhost nexus-2.11.2-03]# cd conf
[root@localhost conf]# vi nexus.properties

# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

第四步:编辑 nexus 脚本, 配置 RUN_AS_USER 参数
[root@localhost conf]# vi /usr/nexus/nexus-2.11.2-03/bin/nexus

NEXUS_HOME="…"
改为(不修改默认也可以):
NEXUS_HOME=“nexus安装目录”

#RUN_AS_USER=
改为:
RUN_AS_USER=root

在这里插入图片描述

启动ok 但是进不去的话可能hi防火墙的问题
开通防火墙端口
firewall-cmd --zone=public --add-port=8081/tcp --permanent

关闭防火墙
systemctl stop firewalld.service

默认用户名:admin
密码:admin123
访问http://ip地址:8081/nexus/

在这里插入图片描述

版本分为
central 私服中央仓库:把远程仓库的索引下载下来
releases版本为最终版本
snapshot为快照版本

上传jar 2种方式 自动/手动

自动
点击central 点击configuration修改选项为true
在这里插入图片描述
查看一下任务
在这里插入图片描述
如果下不来的话 那就对了,因为网络慢

修改pom.xml上传jar到nexus ***************************重点

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>meaven</groupId>
  <artifactId>meaven</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>meaven Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
    </dependency>

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.54</version>
     </dependency>
  </dependencies>
    <!--以下为修改添加代码 -->
  <!--通过deploy上传 -->
  <distributionManagement>
    <repository>
      <id>releases</id>
      <url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
      <id>snapshots</id>
      <url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
    </snapshotRepository>
  </distributionManagement>
  <!-- 下载远程仓库的依赖-->
  <repositories>
    <repository>
      <id>releases</id>
      <url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
    </repository>

    <repository>
      <id>snapshots</id>
      <url>http://192.168.1.138:8081/nexus/content/repositories/releases/</url>
    </repository>
  </repositories>

会根据 1.0-SNAPSHOT 或是 1.0-RELESESA 找到distributionManagement配置的具体上传路径上传
packaging一般为jar 如果是war的话需要配置tomcat在服务器运行

配置maven设置路径内的settings.xml
file>>settings
在这里插入图片描述
复制路径>>打开xml文件>>找到< server>标签
赋值注释内的server内容 添加用户信息按照上传库的名称(和pom.xml保持一致)…这样idea打包的jar包才能上传上去

在这里插入图片描述
点击deploy打包发布到maven管理>>>>>>>>>>>>上传完成
在这里插入图片描述
在这里插入图片描述

页面方式上传

从上到下依次点击选择上传
注意填写的auto guess内容要和pom.xml标签内容一致
在这里插入图片描述
已经可以使用了
在这里插入图片描述

也可以下载公共库的包

  <!--下载库 -->
  <repositories>
    <repository>
      <id>public</id>
      <url>http://192.168.3.138:8081/nexus/content/groups/public/</url>
    </repository>
  </repositories>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值