maven 创建Hadoop程序
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212723859-1001281550.png)
这里用来将新建的maven project 放入到现有的maven working set 中,这样我们就能看到项目之间的层级关系
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212724609-116810322.png)
选择下面的程序
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212724968-2067206069.png)
在父项目中创建公共的pom,在pom中维护项目所需要的各种jar包其中version在properites中指定
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212725327-990592909.png)
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212725718-1577642677.png)
在 midules中添加子模块
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212726155-1171853683.png)
以下是两个主要的plugin
同dependencyManageMent
<pluginManagement>
<plugins>
<!-- maven project model -->
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>${avro.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven.resources.plugin}</version>
</plugin>
</plugins>
</pluginManagement>
设定jdk的版本以及编译版本
<plugins>
<!-- set the jdk version and compile level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins> 子项目中:
设置直系parent
![](https://images2015.cnblogs.com/blog/403274/201605/403274-20160508212726640-1383916196.png)
下面设置avro(阿弗罗自动构建命令)
<build>
<plugins>
<!-- maven project model -->
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-avro-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>schema</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>StringPair.avsc</include>
</includes>
<project>
<groupId>donggege.gege</groupId>
</project>
<sourceDirectory>src/main/resources/avro</sourceDirectory>
<outputDirectory>${project.build.main.directory}</outputDirectory>
<testSourceDirectory>src/main/resources/avro</testSourceDirectory>
<testOutputDirectory>${project.build.test.directory}</testOutputDirectory>
</configuration>
</plugin>
</plugins>
</build>