gpt4 book ai didi

java - 使用java的Sqoop失败

转载 作者:行者123 更新时间:2023-11-29 11:38:45 25 4
gpt4 key购买 nike

我使用下面的代码创建了 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)

我已在类路径中添加了所有依赖项 jar 文件。帮我解决这个问题。

谢谢

最佳答案

我也有同样的问题。经过一步步调试发现是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>

关于java - 使用java的Sqoop失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36175788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com