maven私有仓库nexus3.5搭建与使用

maven私有仓库nexus3.5搭建与使用

参考网址:
http://blog.csdn.net/clj198606061111/article/details/52200928
http://www.cnblogs.com/jingmoxukong/p/6050172.html
http://blog.csdn.net/north_eagle/article/details/42428219

环境
  • 操作系统 ubuntu16.04
  • nexus版本 nexus-3.5.0-02-unix
下载

下载地址:https://www.sonatype.com/download-oss-sonatype

安装
$ sudo tar -zxvf nexus-3.5.0-02-unix.tar.gz -C /usr/local/
$ vim ~/.bashrc
添加
#for nexus
export NEXUS_HOME=/uusr/local/nexus-3.5.0-02
export PATH=$NEXUS_HOME/bin:$PATH
$ source ~/.bashrc
$ nexus start

打开浏览器url http://localhost:8081 用户名admin具有全部权限,默认密码admin123。

配置maven

在$MAVEN_HOME/conf下修改settings.xml

 <pluginGroups>
    <pluginGroup>org.sonatype.plugins</pluginGroup>
  </pluginGroups>

 <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

<mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>

<profiles>
<profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

使用maven编译会首先从nexus私有仓库中下载依赖包,如果nexus私有仓库没有,会从配置的mirror中maven官方中央仓库central中下载,同时存入到nexus私有仓库。

仓库迁移

nexus2.x 到nexus 2.x迁移
直接拷贝仓库目录进行迁移
当前机器上 ${user.home}/sonatype-work copy到新机器的对应位置。这样所有的数据就可以全部恢复。

nexus2.x 到nexus 3.x迁移

配置nexus-2.x的Upgrade #

Administration–>Capabilities–>New–>Upgrade: Agent–>Access Token–>12345678

上面的流程是登陆nexus-2.x配置Upgrade:Agent和Access Token在此我们配置的是12345678

配置nexus-3.x的Upgrade #

Administration–>System–>Capabilities–>Create capability–>Create Upgrade Capability

通过Task迁移数据 #

Administration–>System–>Upgrade–>Next–>URL&access token–>Next…

URL: nexus2.x的url,例如 http://10.10.3.225:8082/nexus
Access Token: 12345678

数据迁移完毕,验证仓库数据。

nexus3.x 到nexus 3.x迁移
暂时未找到方法,采用直接拷贝仓库目录进行迁移,maven编译时会有一些警告信息,并且有些包无法下载。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要配置Maven私有仓库,可以使用Sonatype Nexus 3作为Maven仓库管理器。 以下是配置Nexus 3作为Maven私有仓库的步骤: 1. 安装Nexus 3 可以从Sonatype官网下载Nexus 3,然后按照说明进行安装和配置。 2. 创建Maven仓库Nexus 3中创建Maven仓库,可以通过以下步骤完成: - 登录到Nexus 3的Web界面,并进入“Repositories”页面。 - 点击“Create Repository”按钮,并选择“Maven(hosted)”类型。 - 输入仓库的名称和URL,并选择存储位置等配置信息。 - 点击“Create Repository”按钮,完成仓库创建。 3. 配置MavenMaven的settings.xml文件中配置Nexus 3作为私有仓库,可以通过以下步骤完成: - 打开Maven的settings.xml文件,一般位于${user.home}/.m2/目录下。 - 在<settings>标签内添加如下配置: ``` <mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <url>http://nexus3.example.com/repository/maven-releases/</url> </mirror> </mirrors> ``` 其中,nexus3.example.com/repository/maven-releases/是Nexus 3仓库的URL。 4. 发布和使用Maven包 在使用Nexus 3作为Maven私有仓库时,可以通过以下步骤发布和使用Maven包: - 在项目的pom.xml文件中配置Nexus 3仓库的URL等信息。 - 使用Maven命令发布项目的Maven包到Nexus 3仓库中。 - 在其他项目的pom.xml文件中添加Nexus 3仓库的URL,然后使用Maven命令从Nexus 3仓库中获取依赖。 以上是配置Nexus 3作为Maven私有仓库的基本步骤,具体操作可以根据实际情况进行调整。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值