一、 Maven環(huán)境配置
? ? 1、安裝路徑:
? ? 2、 修改配置文件maven/conf/settings.xml
? ? ? ? 設(shè)置本地倉庫路徑
? ? ? <localRepository>F:/免安裝軟件/apache-maven-3.6.0/repository</localRepository>
? ? ? ? 設(shè)置阿里云服務(wù)器,更快的下載JAR包
<mirror>?
? ? ? ? ? <id>alimaven</id>?
? ? ? ? ? <name>aliyun maven</name>?
? ? ? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url>?
? ? ? ? ? <mirrorOf>central</mirrorOf>?
</mirror>
二、 Hadoop的環(huán)境配置
? ? 1、 解壓文件
? ? 2、 環(huán)境變量配置
三、 IDEA配置
? ? 1、 配置MAVEN環(huán)境
? ? 2、 創(chuàng)建一個(gè)MAVEN項(xiàng)目
? ? 2、 添加依賴
<dependencies>
<dependency>
? ? ? ? ? ? <groupId>org.apache.hadoop</groupId>
? ? ? ? ? ? <artifactId>hadoop-common</artifactId>
? ? ? ? ? ? <version>2.8.4</version>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.apache.hadoop</groupId>
? ? ? ? ? ? <artifactId>hadoop-hdfs</artifactId>
? ? ? ? ? ? <version>2.8.4</version>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.apache.hadoop</groupId>
? ? ? ? ? ? <artifactId>hadoop-client</artifactId>
? ? ? ? ? ? <version>2.8.4</version>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.projectlombok</groupId>
? ? ? ? ? ? <artifactId>lombok</artifactId>
? ? ? ? ? ? <version>1.16.10</version>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>log4j</groupId>
? ? ? ? ? ? <artifactId>log4j</artifactId>
? ? ? ? ? ? <version>1.2.17</version>
? ? ? ? </dependency>
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>org.slf4j</groupId>
? ? ? ? ? ? <artifactId>slf4j-api</artifactId>
? ? ? ? ? ? <version>1.7.7</version>
? ? ? ? </dependency>
? ? ? ? <!-- https://mvnrepository.com/artifact/junit/junit -->
? ? ? ? <dependency>
? ? ? ? ? ? <groupId>junit</groupId>
? ? ? ? ? ? <artifactId>junit</artifactId>
? ? ? ? ? ? <version>4.12</version>
? ? ? ? ? ? <scope>test</scope>
? ? ? ? </dependency>
? </dependencies>
? ? 3、 創(chuàng)建主類
// 1 獲取文件系統(tǒng)
Configuration configuration = new Configuration();
// 配置在集群上運(yùn)行
configuration.set("fs.defaultFS", "hdfs://bigdata111:9000");
FileSystem fileSystem = FileSystem.get(configuration);
// 直接配置訪問集群的路徑和訪問集群的用戶名稱
// FileSystem fileSystem = FileSystem.get(new URI("hdfs://bigdata111:9000"),configuration, "itstar");
// 2 把本地文件上傳到文件系統(tǒng)中
fileSystem.copyFromLocalFile(new Path("F:\\裝機(jī)資料\\mate8信息.txt"), new Path("/mate8信息.txt"));
// 3 關(guān)閉資源
fileSystem.close();
System.out.println("over");
? ? 4、 測試文件上傳