win7 + maven + nexus + Eclipse

来源:互联网 发布:黑马程序员php视频 编辑:程序博客网 时间:2024/06/08 00:04

1.软件安装

1.1、maven下载安装

    apache-maven-3.0-bin.tar.gz下载地址:http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0-bin.tar.gz 
解压,配置环境变量M2_HOME(解压根目录),PATH(bin目录)

1.2、nexus下载安装

   nexus-2.7.0-bundle.tar.gz下载地址:http://nexus.sonatype.org/downloads/

1.2.1 解压并执行

解压后进入nexus-2.7.0-bundle\nexus-2.7.0-06\bin\jsw,根据操作系统类型选择文件夹,我选的是windows-x86-64文件夹bat文件。

1.2.2 运行Nexus

在浏览器中输入:http://localhost:8081/nexus 
就可以看到nexus 的主页,点击右上角Log in 
默认用户名和密码是:admin/admin123 
运行后会自动生成一个nexus工作目录sonatype-work,nexus下载的jar包会存放在 
sonatype-work/nexus/storage中 

1.2.3 配置

点击左侧菜单Repositories 
分别将右侧列表中
1)Apache Snapshots  
2)Codehaus Snapshots  
3)Maven Central 
三个repository 的configuration配置选项中的Download Remote Index 配置改为True,并保存设置, 
然后在列表中分别右键点击三个Repository,点击ReIndex 。true是开启,false是关闭 由于中央仓库内容比较多,因此其索引文件比较大,需要查看下载是否完成了,我们可以单击界面左边导航栏中的 Scheduled Tasks 链接后,就可以看到系统调度的任务其状态为 runing,在说哦因下载完毕之后,该任务就会消失。

2.配置settings.xml

2.1配置本地仓库

<localRepository>D:/work/software/maven/java</localRepository>

2.2在mirrors中添加

 <mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>Nexus Mirror</name>
      <url>http://localhost:8081/nexus/content/groups/public</url>
  </mirror>

2.3在profiles(此处是全局配置)中添加

<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
注:

3.出错处理

3.1 resolution will not be reattempted until the update interval of nexus h

添加更新既可以<updatePolicy>always</updatePolicy>,如下所示
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>

4.Eclipse配置

4.1 安装maven插件

    Eclipse EE版本自带此插件,没有带自己下载

4.2 settings.xml文件

   windows-->preferences-->Maven-->User Settings 选择刚才maven-->conf-->settings.xml(2配置的xml文件)

4.3 配置外置maven

   windows-->preferences-->Maven-->Installations 选择1下载maven
0 0
原创粉丝点击