使用java的Sqoop失败了

时间:2016-03-23 10:36:46

标签: java mysql sqoop

我创建了java程序,使用下面的代码

执行sqoop-1.4.5
String cmd = "import --connect \"jdbc:mysql://ip:3306/test\" --username root --password root --table seekay --target-dir /seekay -m 1";
Sqoop.runTool(cmd.split(" "));

当我运行程序将表从mysql数据库导入到hdfs时,我正处于异常

之下
2016-03-23 15:49:56,260 INFO [Timer-Driven Process Thread-2] org.apache.sqoop.Sqoop Running Sqoop version: 1.4.5
2016-03-23 15:49:56,296 WARN [Timer-Driven Process Thread-2] org.apache.sqoop.tool.BaseSqoopTool Setting your password on the command-line is insecure. Consider using -P instead.
2016-03-23 15:49:56,332 WARN [Timer-Driven Process Thread-2] org.apache.sqoop.ConnFactory $SQOOP_CONF_DIR has not been set in the environment. Cannot check for additional configuration.
2016-03-23 15:49:56,649 ERROR [Timer-Driven Process Thread-2] o.a.sqoop.manager.oracle.OraOopUtilities Unable to determine whether debug logging should be enabled.
java.lang.NullPointerException
    at org.apache.sqoop.manager.oracle.OraOopUtilities.enableDebugLoggingIfRequired(OraOopUtilities.java:239)
    at org.apache.sqoop.manager.oracle.OraOopManagerFactory.accept(OraOopManagerFactory.java:69)
    at org.apache.sqoop.ConnFactory.getManager(ConnFactory.java:184)
    at org.apache.sqoop.tool.BaseSqoopTool.init(BaseSqoopTool.java:247)
    at org.apache.sqoop.tool.ImportTool.init(ImportTool.java:89)
    at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:589)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)

我在classpath中添加了所有依赖jar文件。帮我解决这个问题。

由于

1 个答案:

答案 0 :(得分:1)

我有同样的问题。我发现它是逐步调试后的log4j依赖问题。

我的解决方案是从springframework中排除log4j-over-slf4j:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>