【maven】Nexus使用

试了好几天,总算完成了,发现竟然都不是技术上的问题,都是环境上的问题

 

-------------------------------------------------------------------------------

环境问题:

1. maven的中央库不稳定,经常连接不上去(不知道是本地http代理问题,还确实是中央库的问题)

2. 本地机器太慢,网速太慢

3. nexus连接远端,如果失败,下一次连接时间间隔就会加长,一次间隔比一次间隔长,每次估计要加2分钟左右,这样造成越失败,下一次启动下载时间就越长;

4. nexus要从远端下载index,这个index尺寸比较大,有70M左右(Central库),这样遇到这里机器慢、网速慢的话,下载时间就长,经常认为有问题,就重启了nexus的tomcat,造成永远下载不了。

 

---------------------------------------------------------------------------------------

重新把过程记录一下:

 

  1. 下载nexus的war包(在http://nexus.sonatype.org/downloads/中下载,bundle包在本地运行不了),配置到tomcat中,安装路径为/nexus
  2. 修改nexus的配置:
    在WEB-INF中,文件plexus.properties的nexus-work项,把nexus的数据目录设置成自己要的地方
  3. 启动tomcat,nexus第一次运行,就按照nexus-work项指定的目录创建目录结构
  4. 对nexus进行设置
    1. maven central进行设置:
      主要2点:
      a).把Remote Repository Access中的Download remote Index项设置成true
      b).按照实际环境设置代理
      这2点设置完,配置结束
    2. 配置完,点Save,点了Save数据也不会马上到,要从网上下载70M左右的数据量,原来就是在这里等不起,不断配置,不断重启,造成数据下载中断。
      在下载的时候,可以看一下tomcat的log,会有详细的输出。
      nexus缺省会把配置的所有Repositiry都进行数据下载,每次下载失败就会加大间隔时间再次下载,如果为了log清楚,可以把其他的Repository都删除,只留下Maven Central这一项就可以了(我没这么做,事后想到的) --- 这一步数据到位花的时间最长
    3. 对Public Repository进行设置:
      我在Public Repository中,只留了Maven Central这一项,这样可以明确的看到效果:

           
  5. 本地maven配置:
    修改本地用户的maven setting.xml文件(见附件setting.zip)
    按照文档上说的,修改

    a). 修改本地目录
    <localRepository>D:\zybing\repository</localRepository>

    b).本地nexus镜像所有maven站点:
    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://127.0.0.1:8080/nexus/content/groups/public</url>
    </mirror>
    
     
    c). 增加Profile: 增加了一个repository,一个pluginRepository,都叫central
    <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>
    

    d). 激活这个Profile:
      <activeProfiles>
    	<activeProfile>nexus</activeProfile>
      </activeProfiles>
    
     
  6.  本地运行 mvn help:system,把本地仓库建立起来
  7. 启动Eclipse(已经安装好了m2e了)
    Eclipse启动后,如果maven repository配置好了,自动会下载所需要的资源
    可以在Progress窗口或者Console maven窗口中看到Eclipse做的事情
    当这个工作结束后,就可以工作了

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值