三、Maven与Eclipse集成
1、 下载Maven工具http://maven.apache.org/download.html
2、 安装Maven Integration for Eclipse插件

3、 安装Maven;
a) 解压Maven到本地目录,设置环境变量;
i. MAVEN_HOME为:D:/tools/apache-maven-3.2.1,将bin设置到PATH,在PATH末尾添加:;%MAVEN_HOME%/bin;
ii. 测试MAVEN是否设置成功,在Windows终端输入:mvn –v

b) 设置Maven本地仓库
i. 在D:\tools\apache-maven-3.2.1\conf\settings.xml文件中修改localRepository节点值为D:\study\maven\jar,制定本地仓库地址;

ii. 配置本地仓库nexus(可选)
Nexus下载地址:http://download.sonatype.com/nexus/oss/nexus-2.5.1-bundle.zip
Maven权威指南_中文完整版清晰PDF http://www.linuxidc.com/Linux/2014-06/103690.htm
Maven 3.1.0 发布,项目构建工具 http://www.linuxidc.com/Linux/2013-07/87403.htm
Linux 安装 Maven http://www.linuxidc.com/Linux/2013-05/84489.htm
Maven3.0 配置和简单使用 http://www.linuxidc.com/Linux/2013-04/82939.htm
Ubuntu下搭建sun-jdk和Maven2 http://www.linuxidc.com/Linux/2012-12/76531.htm
Maven使用入门 http://www.linuxidc.com/Linux/2012-11/74354.htm
安装Nexus只需解压配置即可运行
配置Nexus服务

启动Nexus服务(如果运行提示拒绝访问,右键-》管理员身份运行)

登陆Nexus

配置Nexus中心仓库

Nexus+Maven配置

<mirrors> <mirror> <id>nexus</id> <mirrorOf>*</mirrorOf> <name>Nexus Mirror</name> <url>http://maven.oschina.net/content/groups/public</url> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>Nexus</name> <url>http://localhost:8082/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus</name> <url>http://localhost:8082/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> <!--激活配置--> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
4、 eclipse配置Maven;
a) 设置Maven的Installations

b) 设置Maven的User Settings

5、 导入项目工程
a) 在Myeclipse中选择import…依次导入项目工程;

b) 设置启动各个工程的Maven构建

c) 完成环境搭建,启动看效果

--------开发环境准备完毕end------------------------------
2、maven常用操作
a、引入项目中的jar包(使用这种方式引入的JAR包在打包时不会一起打包,所以打包后找不到该JAR包)
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>0.3</version> <scope>system</scope> <systemPath>${project.basedir}/lib/test.jar</systemPath> </dependency>
打包引用包处理方法
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>0.3</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/test.jar</systemPath> </dependency>
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-01/127280.htm
