在Jax中连接Hadoop(Hive apis)数据库 - RS休息服务 - Netbeans

时间:2018-04-12 10:24:31

标签: java rest hadoop hive jax-rs

经过艰苦的努力,我设法使用Jersy -Jax-RS为我的Rest服务提供了一个有效的代码。

我的项目包括使用hadoop数据库的简单数据库操作。不知怎的错误如:

  

组织/阿帕奇/蜂巢/服务/ RPC /节俭/ TCLIService $ IFACE

     

使用-e开关重新运行maven

     

未找到类org.apache.hive.jdbc.HiveDriver

问题是:Hadoop数据库连接需要许多其他支持依赖项,并附带hive-jdbc jar。

请按照POM.xml文件启用所有操作以连接到Hadoop数据库。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.persistentsys.generateresume</groupId>
    <artifactId>GenerateResume</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>RestTest</name>
    <build>
        <finalName>RestTest</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.glassfish.jersey</groupId>
                <artifactId>jersey-bom</artifactId>
                <version>${jersey.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <!-- use the following artifactId if you don't need servlet 2.x compatibility -->
            <!-- artifactId>jersey-container-servlet</artifactId -->
        </dependency>
        <!-- uncomment this to get JSON support
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
        </dependency>
        -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.16</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.1.0.jre8</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-jdbc</artifactId>
            <version>0.13.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libthrift</artifactId>
            <version>0.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.thrift</groupId>
            <artifactId>libfb303</artifactId>
            <version>0.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-core</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-exec</artifactId>
            <version>0.13.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <version>2.5.0</version>
        </dependency>
    </dependencies>
    <properties>
        <jersey.version>2.26-b03</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

1 个答案:

答案 0 :(得分:0)

hive-jdbc是您通过JDBC连接到Hive所需的唯一依赖项,应该找到jdbc驱动程序类。目前尚不清楚你是如何运行代码的

它包含libthrift本身,并且不需要Hadoop依赖项,但如果你确实添加了这些依赖项,那么版本必须匹配。不要混用Hadoop 1.x和Hadoop 2.x

此外,您必须匹配在Hadoop / Hive环境中运行的实际版本。 Hadoop 2.5和Hive 0.13已有几年了