gpt4 book ai didi

java - 在Jax中连接Hadoop(Hive API)数据库-RS Rest Service-Netbeans

转载 作者:行者123 更新时间:2023-12-02 20:40:41 26 4
gpt4 key购买 nike

经过很多努力后,我设法使用Jersy -Jax-RS为Rest服务创建了一个有效的代码。
我的项目包括使用hadoop数据库进行简单的数据库操作。以及类似的错误:

org/apache/hive/service/rpc/thrift/TCLIService$Iface

re-run maven with the -e switch

class not found 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>

最佳答案

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

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

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

关于java - 在Jax中连接Hadoop(Hive API)数据库-RS Rest Service-Netbeans,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49794117/

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