我创建了一个带依赖关系的maven项目
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
我面临private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
java.lang.ClassNotFoundException: org.apache.hadoop.hive.jdbc.HiveDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at sample.HiveJdbcClient.main(HiveJdbcClient.java:18)
答案 0 :(得分:2)
我想你需要这个:
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>2.3.2</version>
</dependency>
根据HiveServer2的运行情况更改版本
https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc/2.3.2