【问题标题】:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient线程“主”java.lang.NoClassDefFoundError 中的异常:org/apache/http/client/HttpClient
【发布时间】:2020-10-27 07:04:15
【问题描述】:

谁能帮我解决以下问题。下面是代码sn-p。

try {
            Class.forName("org.apache.hive.jdbc.HiveDriver");
            Connection con = DriverManager.getConnection("jdbc:hive2://host:port", "user", "nc_admin");
            System.out.println(con);
            Statement stmt = con.createStatement();
            System.out.println(stmt);
        } catch (ClassNotFoundException e) {

            e.printStackTrace();
        } catch (SQLException e) {

            e.printStackTrace();
        }
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient

【问题讨论】:

    标签: java http httpclient apache-httpclient-4.x


    【解决方案1】:

    如果是 maven 项目,请使用这个 pom。

    <!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc -->
    <dependency>
        <groupId>org.apache.hive</groupId>
        <artifactId>hive-jdbc</artifactId>
        <version>3.1.2</version>
    </dependency>
    

    或从这里下载 jar

    hive driver

    【讨论】:

    • 3.1.2 有一些问题,构建不成功。 1.1.1 构建成功。所以问题不在于驱动程序。 httpclient 的问题。
    猜你喜欢
    • 1970-01-01
    • 2011-02-10
    • 2017-03-24
    • 1970-01-01
    • 2019-07-03
    • 2013-09-29
    • 2013-03-19
    • 2018-08-09
    • 2017-11-22
    相关资源
    最近更新 更多