1_maven与eclispe环境搭建
【1】eclipse 4.3以前的版本需要为eclipse安装m2e插件。可以采用link,marketplace或install new software来安装(参照其他文章)
本文使用的是eclipse Kepler 4.3已经自己集成了maven插件。
集成好后,在eclipse window-Preferences 下面多出了maven选项
【2】需要配置Installations,配置外置的maven,也就是文章1中配置好的maven环境。
使用Add按钮,添加本地的maven。
2_利用eclipse创建maven项目了。
(1) New --Maven--Maven Project
(2) 设置项目存储位置
(3)设置创建maven项目的模板
quickstart是创建普通java项目的模板,webapp是创建web项目的模板,在文章2 中有讲解。
(4)设置 Maven坐标
设置完成即可完成项目的创建。
3_利用eclipse进行项目的构建,测试,运行。
【1】右键pom.xml,Run as
【2】也可以自定义运行的命令,点击2 Maven build..然后输入自定义命令。
【3】如果是web项目,可以在pom.xml中配置cargo,使其自动部署到tomcat上。
<build>
<finalName>web1</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<home>D:\Tomcat7.0</home>
</container>
<configuration>
<type>existing</type>
<home>D:\Tomcat7.0</home>
</configuration>
</configuration>
<executions>
<execution>
<id>cargo-run</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
以上为简单配置,后续会专门讲解cargo的配置