maven私有仓库快速使用指南(nexus)

管理maven的仓库目前知道的有三种

archiva, artifactory以及nexus,貌似nexus目前最流行。放上下载地址https://www.sonatype.com/oss-thank-you-zip

目前我下的是nexus-2.14.2-01-bundle.zip 运行这个东西首先需要JDK。所以我们需要首先安装JDK1.8

以centos 为例,大概就这么几步

yum update (更新这事看你爱好吧,一般不跑也没事)

rpm -qa | grep -E ‘^open[jre|jdk]|j[re|dk]’ (查老版本的JDK有没有) 

加入有老版本的话,需要

yum remove java-1.6.0-openjdk 
yum remove java-1.7.0-openjdk 

系统干净了。就赶紧去这个地址下载http://www.oracle.com/technetwork/java/javase/downloads/index.html  oracle jdk 1.8

我下的是jdk-8u25-linux-x64.rpm 然后打安装的命令

rpm -ivh jdk-8u25-linux-x64.rpm 

现在oracle jdk 1.8就安装完成了

然后进入nexus的解压目录  ./bin/nexus start  运行起来看看。

运行tail -f logs/wrapper.log可以看到这次启动的结果

没问题的话。输入ip:8081/nexus就可以看到启动画面啦

首先是登陆,默认账号密码  admin   admin123

进入central的configuration,设置Download Remote Indexes 为true

apache snapshot也可以设置。

下面是使用

在pom.xml中增加  这层的上一层就是<project>

  <repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus</name>
            <url>http://x.x.x.x:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Nexus</name>
            <url>http://x.x.x.x:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

好了。这样这个项目就可以使用了

所有项目使用需要改变setting.xml

<mirrors>
              <mirror>
                     <id>nexus</id>
                     <mirrorOf>*</mirrorOf>
                     <url>http://x.x.x.x:8081/nexus/content/groups/public</url>
              </mirror>
</mirrors>

也可以用别人私服,,谷歌和oschina的(暂未验证)

  <mirrors>
    <mirror>
      <id>google-maven-central</id>
      <name>Google Maven Central</name>
      <url>https://maven-central.storage.googleapis.com</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <mirrors>
    <mirror>
      <id>nexus-osc</id>
      <mirrorOf>*</mirrorOf>
      <name>Nexus osc</name>
      <url>http://maven.oschina.net/content/groups/public/</url>
    </mirror>
  </mirrors>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值