使用Nexus搭建Maven私服

1.下载nexus安装包
https://www.sonatype.com/download-oss-sonatype

2.上传到服务器解压安装

tar -zxvf nexus-3.13.0-01-unix.tar.gz

3.重命名

mv nexus-3.13.0-01 nexus

4.切换至nexus

cd nexus

5.nexus相关命令

./bin/nexus start | stop | status

6.访问
http://ip:8081

默认账号密码:admin/admin123

7.修改账号密码之类
可视化界面操作,可以根据自己的需要操作

8.配置maven的setting.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
    <server>
      <id>【私服id,需跟server一样】</id>
      <username>【账号】</username>
      <password>【密码】</password>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>aliyun-maven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
    <mirror>     
      <id>【私服id,需跟server一样】</id>     
      <mirrorOf>*</mirrorOf>     
      <url>【私服地址】/</url>     
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>jdk1.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>
      <repositories>
        <repository>
          <id>【私服id,跟server一致】</id>
          <url>【私服地址】</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>

9.IDEA配置
IDEA --> file --> settings --> 搜索Maven --> User settings file Override --> 选择setting.xml–> Apply --> OK

10.打包上传到私服
IDEA右栏 --> MAVEN --> 找到对应项目 --> Lifecycle --> deploy --> build

11.查看控制台或私服目录看是否上传成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
搭建Maven私服可以使用Sonatype Nexus,它是一个功能强大的仓库管理器,可以帮助我们创建和管理Maven私服。下面是基于Nexus搭建Maven私服的详细步骤: 1. 准备环境:首先,确保你已经安装了Java环境,并且可以正常运行MavenNexus软件。 2. 下载和解压缩Nexus软件:从Sonatype官方网站下载最新版本的Nexus软件,并解压缩到合适的目录中。 3. 启动Nexus使用命令行窗口进入Nexus软件的目录,然后执行 `./bin/nexus start` 命令来启动Nexus服务器。 4. 访问Nexus控制台:在浏览器中输入 `http://localhost:8081` 访问Nexus控制台,默认用户名和密码都是 `admin`,登录成功后,可以看到Nexus的管理界面。 5. 创建Maven仓库:在Nexus控制台中,点击左侧菜单的 `Repositories`,然后点击 `Create repository` 来创建新的Maven仓库。根据需要选择 `Hosted repository` 或者 `Proxy repository`,然后填写相应的配置信息,如仓库名称、URL、布局等。 6. 配置Maven项目:在你的Maven项目的pom.xml文件中添加Nexus私服的配置信息,包括ID、URL等,用来指定将Maven构建输出部署到Nexus仓库中。 7. 部署和使用使用 `mvn deploy` 命令将项目打包并部署到Nexus私服中,当其他开发人员或者CI/CD服务器需要下载依赖时,只需要修改项目的settings.xml文件,指定Nexus私服的URL和凭据即可。 8. 其他设置:你还可以在Nexus控制台里进行其他设置,比如用户管理、访问控制、仓库代理等。 总结一下,使用Nexus搭建Maven私服非常简单,只需要几个基本的步骤即可完成。通过搭建Maven私服,我们可以有效地管理和共享项目的依赖包,提升团队的开发效率和项目的可维护性。这对于生产环境中的项目非常重要。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值