1.构建java工程
创建普通应用项目:
mvn archetype:create -DgroupId=com.byread -DartifactId=blog
创建WEB项目:
mvn archetype:create -DgroupId=com.byread -DartifactId=blogweb -DarchetypeArtifactId=maven-archetype-webapp
2.添加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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testw</groupId>
<artifactId>Test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>0.8.0-incubating</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 设定complier,指定jdk mvn compiler:compile -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.6</target>
<source>1.6</source>
<encoding>UTF-8</encoding>
<skip>true</skip>
</configuration>
</plugin>
<!-- 自定义资源文件编码-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!--设定jar依赖,使jar包包含整个依赖信息 ,亦可设置war包-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<finalname>firsttest</finalname>
<configuration>
<descriptorRefs>
<descriptorRef> jar-with-dependencies </descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
3.编译执行命令
3.1:compiler: mvn compiler:compile
3.2:build.bat
mvn clean package -Dmaven.test.skip=true assembly:assembly
pause
3.3:生成eclipse工程,eclipse.bat
call mvn -U eclipse:clean eclipse:eclipse -DdownloadJavadocs=true -DdownloadSources=true
@pause
3.4:打jar包
call mvn package -Dmaven.test.skip=true
@pause
创建普通应用项目:
mvn archetype:create -DgroupId=com.byread -DartifactId=blog
创建WEB项目:
mvn archetype:create -DgroupId=com.byread -DartifactId=blogweb -DarchetypeArtifactId=maven-archetype-webapp
2.添加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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testw</groupId>
<artifactId>Test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>0.8.0-incubating</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 设定complier,指定jdk mvn compiler:compile -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.6</target>
<source>1.6</source>
<encoding>UTF-8</encoding>
<skip>true</skip>
</configuration>
</plugin>
<!-- 自定义资源文件编码-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!--设定jar依赖,使jar包包含整个依赖信息 ,亦可设置war包-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<finalname>firsttest</finalname>
<configuration>
<descriptorRefs>
<descriptorRef> jar-with-dependencies </descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
3.编译执行命令
3.1:compiler: mvn compiler:compile
3.2:build.bat
mvn clean package -Dmaven.test.skip=true assembly:assembly
pause
3.3:生成eclipse工程,eclipse.bat
call mvn -U eclipse:clean eclipse:eclipse -DdownloadJavadocs=true -DdownloadSources=true
@pause
3.4:打jar包
call mvn package -Dmaven.test.skip=true
@pause