Maven + Nexus + Eclipse
1. 需要的软件
JDK(下载,安装,使用略)
Maven 3.0.5
网页下载地址:/i
eclipse(建议用indigo版)。
2.maven的安装使用
2.1.解压
下载apache-maven-3.0.5-bin.zip后解压。本指南以解压到D:\Program Files\apache-maven-3.0.5为例。
2.2.配置环境变量
为了方便使用mvn命令,配置环境变量。
将bin添加到path中:
%M2_HOME%\bin\
检验安装是否正常
命令行中查看:mvn-help
2.3.maven配置文件l
配置文件位置:%M2_HOME%\conf
需要添加的内容如下:
// 本地存放依赖包的位置,不写的话,默认存放在C:\Documents and Settings\Administrator\.m2\repository中。
<localRepository>D:/nexus/.m2/repository</localRepository>
//关联nexus库
<servers>
    <server>
    <id>nexus-releases</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    <server>
    <id>nexus-snapshots</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
</servers>
<mirrors>
    <mirror>
<id>nexus</id>
<url>192.168.71.67:8081/nexus/content/groups/public</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
    <url>192.168.71.67:8081/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
        <url>192.168.71.67:8081/nexus/content/groups/public</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
3.eclipse的maven插件
3.1.maven插件下载安装
  方式有两种:在线,离线。
在线安装
Eclipse的help Install New Software 弹出窗口后点击Add,输入网址:ttp:///sites/m2e。把选项勾上后,等待下载安装,然后重启即可。
PS:我安装时,在线安装并不成功,网址不能访问。推荐离线安装。
离线安装:
在eclipse的解压包中,新建文件夹mypluginslinks。在links中,添加maven.link文件,内容指向插件存放地址,例如:path=D:/Program Files/eclipse/myplugins/maven
在文件夹myplugins中,存放已经下载的插件,结构如下:
Myplugins - > maven - > eclipse ----features
                                ----plugins
lipse的插件配置
Window preferences
4.创建项目

项目创建成功。
调整项目结构如下:
导入既存代码
不要把依赖包jar直接导入项目,maven项目是根据pom文件来自动从nexus私服下载依赖包的。以下为pom文件的基本内容。
以下是pom文件的主要部分:
项目可打包发布到nexus上。
增添插件
增添依赖包
增添代码编译的文件类型
5.项目运行及debug
进入configuration页面
新增运行项目
添加内容
可以运行或debug了。
6.从SVN检出Maven工程
下载maven的svn插件,插件地址:/maven2/.m2e/connectors/m2eclipse-subclipse/0.13.0/N/0.13.0.201303011221/
检出Maven工程代码
eclipse导入整个项目
选择svn中的代码,点击下一步直到完成。