以Eclipse为核心搭建JAVA WEB开发环境(二)-Maven Nexus

本篇介绍安装Maven和Nexus。

 

1、下载安装Maven。

    虽然Eclipse内嵌的maven,但是如果想配置个性的Maven还是需要安装一个完整版。

    下载地址:http://maven.apache.org/download.html

    下载最新版本的Maven。

    解压到某个目录下即可。后面用${MAVEN_HOME}代替这个目录。

 

2、下载Nexus。

    下载地址:http://www.sonatype.org/nexus/go

    nexus有几个发布形式,我选择war distrubution,应为比较好配置。也可以用其他形式配置成系统服务。

 

3、安装Nexus。

    将下载的nexus-x.x.x.war拷贝到WEB服务器里,我用Tomcat,所以拷贝到Tomcat的webapps下。

    重命名为nexus.war。

    启动Tomcat,浏览http://localhost:8080/nexus,显示nexus首页就对。

 

4、配置Nexus。

    英文配置文档可以参考:http://www.sonatype.com/books/nexus-book/reference/

    1)修改管理员密码。

        管理员默认登录名和密码是:admin/admin123

        登陆路后,选在左侧菜单Security-->Change Password

 

    2)设置SMTP

        nexus可以发送重置密码邮件,如果需要这个功能,就需要配置SMTP。

        左侧菜单Administration-->Server-->SMTP Settings。

        设置好后可以“Test SMTP settings”

 

    3)允许下载远程索引

        Nexus代理3个重要的仓库:Maven Central repository、Apache Snapshot repository、Codehaus Snapshot repository。大多数仓库为了快速搜索都提供索引文件。Nexus默认设置关闭了下载远程索引文件,打开的方法:

        左侧菜单Views/Repositories-->Repositories 选择Apache Snapshots 点击Configration选项卡,变更Download Remote Indexes为True。

 

    4)设置部署员账号密码。

        nexus默认有一个部署权限的账号。deployment/deployment123。

        管理员登陆,左侧菜单Security-->Users 右键点击deployment用户,选择Set Password


5、配置Maven

    打开${MAVEN_HOME}/conf/settings.xml

    1)去掉localRepository的注释,编辑本地仓库的地址。


2)添加如下配置

 

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <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>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>
 

 

6、配置Eclipse的Maven。

Eclipse菜单,Window-->Preferences。打开左侧Maven项目:


点击Add按钮,选中${MAVEN_HOME}目录。


点确定按钮。结果如下图:


再选中User Settings,如下设置:


点击Update Settings按钮和Reindex按钮。

Eclipse会自己工作一段时间,之后就可以使用了。

关于nexus其他操作可以参考网上的使用手册,比如增加自定义的仓库,设置仓库组,设置计划任务等。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值