目前在网上能够看到的关于Maven的教程大多是一些基本的设置,但是用于一个完整的项目开发的并不是很多(如果大家有,欢迎回复),只能自己一点点整了。
1、安装Maven2.0.4;
2、运行mvn;
这个主要是为了能够在%user_profile%/目录下创建.m目录。这个目录是maven的默认工作目录。
3、创建一个基本的eclipse项目;
mvn archetype:create -DgroupId=org.powersoft -DartifactId=app
mvn eclipse:eclipse
4、创建一个webapp;
mvn archetype:create -DgroupId=org.powersoft -DartifactId=hrms -DarchetypeArtifactId=maven-archetype-webapp
5、将生成的src/main下的webapp目录拷贝到在第3步中创建的eclipse项目中的src/main目录下;
这个将作为web的根目录
6、将以上创建的项目导入到eclisep工程中;
7、由于我们将在项目使用Spring,hibernate和xfire,修改pom.xml文件
<project xmlns="
http://maven.apache.org/POM/4.0.0"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.powersoft</groupId>
<artifactId>hrms</artifactId>
<packaging>war</packaging>
<name>Maven Quick Start Archetype</name>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.0.cr5</version>
</dependency>
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-aegis</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-core</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-annotations</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-spring</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-xmlbeans</artifactId>
<version>1.2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.mortbay.jetty</groupId>
<artifactId>
maven-jetty-plugin</artifactId>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<contextPath>/hrmsweb</contextPath>
<systemProperties>
<systemProperty>
<name>org.apache.commons.logging.Log</name>
<value>org.apache.commons.logging.impl.SimpleLog</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
8、在eclipse中启用maven2的plugin,将会看到一些jar在下载,可以喝咖啡去了
9、运行mvn jetty:run,将启动jetty web server。
这样你就可以跟往常使用eclipse开发项目一样,编写类了,这个jetty插件会自动检测代码修改,并重新部署应用。