Maven3.1.1+nexus1.9

nexus建好后,本机安装maven,过程不写了,注意环境变量配置,新建变量名:M2_HOME  值:D:/apache-maven-3.1.1/,

path 加入:%M2_HOME%;

使用的是3.1.1,maven放在D:/apache-maven-3.1.1/,conf目录下setting.xml文件修改本地仓库位置:

 <localRepository>D:/apache-maven-3.1.1/repository</localRepository>

profiles中添加:

<profile> 
      <id>nexus</id> 
      <repositories> 
        <repository> 
            <id>nexus</id> 
            <name>local private nexus</name> 
            <url>http://10.21.1.41:8081/nexus/content/repositories/thirdparty/</url> 
            <releases><enabled>true</enabled></releases> 
            <snapshots><enabled>false</enabled></snapshots> 
        </repository>
      </repositories> 
      <pluginRepositories> 
        <pluginRepository> 
            <id>nexus</id> 
            <name>local private nexus</name> 
            <url>http://10.21.1.41:8081/nexus/content/repositories/thirdparty/</url> 
            <releases><enabled>true</enabled></releases> 
            <snapshots><enabled>false</enabled></snapshots> 
        </pluginRepository> 
       </pluginRepositories>


repositories是仓库引用, pluginRepositories是插件仓库,setting.xml最下面激活该配置:

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

这样本机使用maven都能使用thirdparty的jar,pom.xml中不用再写thirdparty的repositories、pluginRepositories。

eclipse/MyEclipse安装Maven插件,设置maven:


插件setting设置:


仓库会和setting中设置的一致,那么jar从私服上下载后放在这里,以后出现jar引用错误,直接在这里找对应目录,正确下面会有

eclipse建立maven,不写了,打开pom.xml,如要引用lucene的jar,直接复制

中的xml到pom.xml,转到该pom.xml的目录,运行mvn install,从私服下载jar到本地仓库D:/apache-maven-3.1.1/repository,再看eclipse中:

lucene自动加入,再看仓库下D:/apache-maven-3.1.1/repository/com/xxx/lucene/2.4.0,目录结构和私服上完全一致。

如果出现错误,多半是下载有误,直接看对应目录下,有时只有.lastUpdated文件,无jar,可以删除仓库下的目录重新mvn install,如果下载了私服中没有的包,可能是私服有修改,先删除本地包,在私服中Reindex,应该就没有问题。


多个eclipse,多个workspace,多个项目,总是为了方便,每次都复制包,重复的太多,版本也不好管理,maven+nexus自己只是用做jar管理,仓库保管一次,按版本分类,项目中pom.xml引入就行。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值