使用Maven搭建Hadoop2.7.3项目

参考:win 10 + maven + idea 15 + Hadoop 2.7.3开发环境配置
参考:用Maven构建Hadoop项目
官方文档:http://maven.apache.org/

pom.xml:



    4.0.0

    myHadoop
    myHadoop
    1.0-SNAPSHOT
    
        UTF-8
        2.7.3
    
    
        
            junit
            junit
            4.12
        
        
            org.apache.hadoop
            hadoop-client
            ${hadoop.version}
        
        
            org.apache.hadoop
            hadoop-common
            ${hadoop.version}
        
        
            org.apache.hadoop
            hadoop-hdfs
            ${hadoop.version}
        
    


报错:

log4j:WARN No appenders could be found for logger (dao.hsqlmanager).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

解决办法:
http://stackoverflow.com/questions/12532339/no-appenders-could-be-found-for-loggerlog4j

Just to get you going you have two simple approaches you can take.
First one is to just add this line to your main method:

BasicConfigurator.configure();

Second approach is to add this standard log4j.properties (taken from the above mentioned guide) file to your classpath:

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

你可能感兴趣的:(使用Maven搭建Hadoop2.7.3项目)