maven2管理打包项目
1、MAVEN命令
查看版本 mvn --version
编译源代码 mvn compile
编译测试代码 mvn test-compile
运行测试 mvn test
产生site mvn site
打包 mvn package
在本地Repository中安装jar mvn install
清除产生的项目 mvn clean
2、集成测试
定义了测试的源码目录和配置文件目录等
<testSourceDirectory>${basedir}/src/test</testSourceDirectory>
<testOutputDirectory>
${basedir}/WebRoot/WEB-INF/classes
</testOutputDirectory>
<testResources>
<testResource>
<directory>${basedir}/src/conf</directory>
</testResource>
</testResources>
3、pom.xml实例:
<?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>athena</groupId>
<artifactId>athena</artifactId>
<packaging>war</packaging>
<name />
<version>0.0.1-SNAPSHOT</version>
<description />
<build>
<!-- 打出的war包的名字 -->
<finalName>athena</finalName>
<sourceDirectory>${basedir}/src/java</sourceDirectory>
<outputDirectory>
${basedir}/WebRoot/WEB-INF/classes
</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/conf</directory>
<excludes>
<exclude>**/athena.properties</exclude>
</excludes>
</resource>
</resources>
<testSourceDirectory>${basedir}/src/test</testSourceDirectory>
<testOutputDirectory>
${basedir}/WebRoot/WEB-INF/classes
</testOutputDirectory>
<testResources>
<testResource>
<directory>${basedir}/src/conf</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>
${basedir}/WebRoot
</webappDirectory>
<warSourceDirectory>
${basedir}/WebRoot
</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
1、MAVEN命令
查看版本 mvn --version
编译源代码 mvn compile
编译测试代码 mvn test-compile
运行测试 mvn test
产生site mvn site
打包 mvn package
在本地Repository中安装jar mvn install
清除产生的项目 mvn clean
2、集成测试
定义了测试的源码目录和配置文件目录等
<testSourceDirectory>${basedir}/src/test</testSourceDirectory>
<testOutputDirectory>
${basedir}/WebRoot/WEB-INF/classes
</testOutputDirectory>
<testResources>
<testResource>
<directory>${basedir}/src/conf</directory>
</testResource>
</testResources>
3、pom.xml实例:
<?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>athena</groupId>
<artifactId>athena</artifactId>
<packaging>war</packaging>
<name />
<version>0.0.1-SNAPSHOT</version>
<description />
<build>
<!-- 打出的war包的名字 -->
<finalName>athena</finalName>
<sourceDirectory>${basedir}/src/java</sourceDirectory>
<outputDirectory>
${basedir}/WebRoot/WEB-INF/classes
</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/conf</directory>
<excludes>
<exclude>**/athena.properties</exclude>
</excludes>
</resource>
</resources>
<testSourceDirectory>${basedir}/src/test</testSourceDirectory>
<testOutputDirectory>
${basedir}/WebRoot/WEB-INF/classes
</testOutputDirectory>
<testResources>
<testResource>
<directory>${basedir}/src/conf</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>
${basedir}/WebRoot
</webappDirectory>
<warSourceDirectory>
${basedir}/WebRoot
</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>