mvn archetype:generate -DgroupId=my.hadoopstudy -DartifactId=hadoopstudy -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
2. 然后在pom.xml文件里添加hadoop的依赖包hadoop-common, hadoop-client, hadoop-hdfs,添加后的pom.xml文件如下
[html] view plain copy
4.0.0
my.hadoopstudy
hadoopstudy
jar
1.0-SNAPSHOT
hadoopstudy
org.apache.hadoop
hadoop-common
2.5.1
org.apache.hadoop
hadoop-hdfs
2.5.1
org.apache.hadoop
hadoop-client
2.5.1
junit
junit
3.8.1
test
3. 测试
3.1 首先我们可以测试一下hdfs的开发,这里假定使用上一篇Hadoop文章中的hadoop集群,类代码如下
[java] view plain copy
package my.hadoopstudy.dfs;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.