HDFS API操作
在Windows上操作hadoop,需要添加hadoop依赖,我的hadoop是3.3.1版本的,我用的依赖是3.2.0的,需要配置环境变量
PATH添加如下路径:
然后双击依赖中的
一闪而过就是成功的。
在maven项目中添加如下依赖
<dependencies> <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-client --> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>3.2.0</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.30</version> <scope>test</scope> </dependency> </dependencies>
一开始忘记了<dependencies>标签,导致一直报错。
然后在src/main/resources目录下,新建log4j.properties文件夹,在文件夹中填入.
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=target/spring.log
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
标签:appender,hadoop,Hadoop,apache,org,logfile,十九,log4j From: https://www.cnblogs.com/zhaolei0419/p/16606990.html