1、MAVEN的安装和配置
项目地址:
http://maven.apache.org/download.html

下载到的文件:
apache-maven-2.0.9-bin.zip

接压缩后拷贝到tool下面。配置path中加入:
D:\tool\apache-maven-2.0.9\bin

然后在命令行中输入:
mvn -version

返回:
Maven version: 2.0.9
Java version: 1.5.0_12
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
maven就安装好了

maven命令
mvn test:运行应用程序中的单元测试
mvn package:依据项目生成jar文件
mvn install,把包安装在本地的repository中,可以被其他工程作为依赖来使用
mvn site:生成项目相关信息的网站
mvn clean:清除目标目录中的生成结果
mvn eclipse:eclipse:生成Eclipse项目文件
mvn deploy,在整合或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享。

可以通过对目标及相位的组合使得一个命令完成多个功能,比如:
mvn clean dependency:copy-dependencies package
关于常用命令的详解,见参考资料。

2、MYECLIPSE6.5
项目地址:
http://www.myeclipseide.com/

SN:
Subscriber: xiaofei
Subscription Code: kLR8ZO-655111-53678656277609555

新建WEB项目的时候ADD MAVEN的支持

3、MAVEN和MYECLIPSE
目前是只用MAVEN来管理JAR包,pom.xml文件如下,删除其中build的配置:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sillycat</groupId>
<artifactId>easyview</artifactId>
<packaging>war</packaging>
<name />
<version>0.0.1-SNAPSHOT</version>
<description />
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>com.ibatis</groupId>
<artifactId>ibatis2-dao</artifactId>
<version>2.1.7.597</version>
</dependency>
</dependencies>
</project>

运行如下命令:
mvn clean dependency:copy-dependencies
会生成target/dependency目录,将jar包拷贝到dependency目录

还是使用ant来编译打包,其实这样比较土,不过自己用起来比较熟悉。先用

mvn clean dependency:copy-dependencies

然后用

ant war 打包,两个过程了。。。。

build.xml如下:
<!-- modified by sillycat.luohua 2008.06.27 -->
<project name="easyview" default="compile" basedir=".">
<!-- set global properties for this build -->
<!-- 项目名字 -->
<property name="project" value="easyview" />
<!-- 源代码路径 -->
<property name="src" location="src/java" />
<!-- 所有的配置文件 -->
<property name="config" location="src/conf" />
<!-- web项目的根 -->
<property name="web" location="WebRoot" />
<!-- web中用到的jar包 -->
<property name="web-lib" location="${web}/WEB-INF/lib" />
<!-- build出class的路径 -->
<property name="build" location="build" />
<!-- 生成war包和项目部署配置文件的路径 -->
<property name="dist" location="dist" />
<!-- maven管理的jar包 -->
<property name="maven-jar" location="target/dependency" />

<!-- 编译项目的classpath设置 -->
<path id="classpath.compile">
<fileset dir="${web-lib}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${build}" />
</path>

<target name="init">
<!-- 编译前先生成目录 -->
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<copy todir="${web-lib}">
<fileset dir="${maven-jar}" includes="*.jar">
</fileset>
</copy>
</target>

<target name="compile" depends="init" description="compile the source">
<mkdir dir="${build}/classes" />
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}/classes" debug="true" deprecation="true" optimize="false" failonerror="true" encoding="utf-8">
<classpath refid="classpath.compile" />
</javac>
</target>

<!-- 拷贝页面资源到build中 -->
<target name="copyWebFiles" depends="compile">
<mkdir dir="${build}/web" />
<copy todir="${build}/web">
<fileset dir="${web}" excludes="WEB-INF/classes/">
</fileset>
</copy>
<copy todir="${build}/web/WEB-INF/classes">
<fileset dir="${build}/classes">
</fileset>
<fileset dir="${config}">
<exclude name="**/easyview.properties" />
</fileset>
</copy>
</target>

<!-- 拷贝配置资源给本机测试用 -->
<target name="config4debug">
<copy file="${config}/easyview.properties" tofile="${dist}/easyview.properties" />
</target>

<!-- 拷贝配置资源给发布用 -->
<target name="config4release">
<copy file="${config}/easyview.properties" tofile="${dist}/easyview.properties" />
</target>

<!-- 生成war包 -->
<target name="buildWar">
<mkdir dir="${dist}" />
<war destfile="${dist}/${project}.war" webxml="${build}/web/WEB-INF/web.xml">
<fileset dir="${build}/web" />
</war>
</target>

<!-- 打包给本机测试 -->
<target name="war" depends="clean,copyWebFiles,config4debug,buildWar" description="generate the war package for personal debug">
</target>

<!-- 打包给发布使用 -->
<target name="release" depends="clean,copyWebFiles,config4release,buildWar" description="generate the war package for release">
</target>
<!-- 编译打包前先清空 -->
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>