1、安装maven
1.1 下载maven
1.2 解压到本地的目录下
1.3 将meven的安装目录加入到/etc/profile文件中
1 export M2_HOME=/soft/maven/apache-maven-3.6.0 2 export CLASSPATH=$M2_HOME/lib:$CLASSPATH 3 export PATH=$PATH:$M2_HOME/bin:$PATH
1.4 运行命令maven -verson 验证是否安装成功
2、设置maven的settings.xml文件
2.1 修改本地仓库的位置
1 <localRepository>/soft/maven/apache-maven-3.6.0/localrepository</localRepository>
2.2 修改镜像源
1 <mirror> 2 <id>alimaven</id> 3 <name>aliyun maven</name> 4 <url>http://maven.aliyun.com/nexus/content/groups/public/</url> 5 <mirrorOf>central</mirrorOf> 6 </mirror> 7 </mirrors>
3、配置eclipse的环境
注意一下只配置global setting
user seeting 默认就行,否则出现许多问题
4、新建一个maven项目,一切都默认
然后再pom.xml文件加入以下代码
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!-- 定義一個變量 --> <hadoop.version>3.1.1</hadoop.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- JDK依賴 --> <dependency> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId> <version>1.8</version> <scope>system</scope> <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath> </dependency> <!-- hadoop start --> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-hdfs</artifactId> <version>${hadoop.version}</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>${hadoop.version}</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <version>${hadoop.version}</version> </dependency> <!-- hadoop end -->