`
zybing
  • 浏览: 447716 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

【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做的事情
    当这个工作结束后,就可以工作了

 

 

分享到:
评论
1 楼 marshan 2012-08-04  
good summary.

相关推荐

Global site tag (gtag.js) - Google Analytics