datart读取hive数据时,需要先在datart的lib目录下导入hive jdbc相关的包,这里面有几个坑记录下:
1.和springboot中commons-lang3冲突
2.hive中带的jetty和springboot冲突
3.hive jdbc的包的版本号一定要小于登录hive服务端的版本,否则会报Required field ‘client_protocol’ is unset的错误,在引入hive jdbc包的时候,要先查看hive的版本,具体方法:可以找到hive的安装目录 whereis hive,查看hive lib目录下相关包的版本或者执行hive后,通过查看日志得到hive的版本。
最后在导入包的时候,一个个导比较麻烦,而且针对jar包冲突请求也不好处理,所以新建了个项目将所需的包引入,使用maven-shade-plugin插件进行打包并对冲突了的jar包进行重命名,消除冲突,最后的pom文件如下:
- "1.0" encoding="UTF-8"?>
- <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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0modelVersion>
-
- <groupId>org.examplegroupId>
- <artifactId>hive-dependencyartifactId>
- <version>1.0-SNAPSHOTversion>
-
-
- <properties>
- <maven.compiler.source>8maven.compiler.source>
- <maven.compiler.target>8maven.compiler.target>
- <hive.version>1.1.0hive.version>
- properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.hivegroupId>
- <artifactId>hive-jdbcartifactId>
- <version>${hive.version}version>
- dependency>
- <dependency>
- <groupId>org.apache.hadoopgroupId>
- <artifactId>hadoop-commonartifactId>
- <version>2.6.0version>
- dependency>
- <dependency>
- <groupId>org.apache.hadoopgroupId>
- <artifactId>hadoop-clientartifactId>
- <version>2.7.1version>
- dependency>
- <dependency>
- <groupId>org.apache.hivegroupId>
- <artifactId>hive-execartifactId>
- <version>${hive.version}version>
- <exclusions>
- <exclusion>
- <artifactId>commons-lang3artifactId>
- <groupId>org.apache.commonsgroupId>
- exclusion>
- exclusions>
- dependency>
- dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-pluginartifactId>
- <configuration>
- <source>1.8source>
- <target>1.8target>
- <encoding>UTF-8encoding>
- configuration>
- plugin>
-
- <plugin>
- <groupId>org.apache.maven.pluginsgroupId>
- <artifactId>maven-shade-pluginartifactId>
- <version>2.4.3version>
- <executions>
- <execution>
- <phase>packagephase>
- <goals>
- <goal>shadegoal>
- goals>
- <configuration>
- <filters>
- <filter>
- <artifact>*:*artifact>
- <excludes>
- <exclude>META-INF/*.SFexclude>
- <exclude>META-INF/*.DSAexclude>
- <exclude>META-INF/*.RSAexclude>
- <exclude>org/eclipse/*exclude>
- excludes>
- filter>
- filters>
- <relocations>
- <relocation>
- <pattern>org.apache.commons.lang3pattern>
- <shadedPattern>org.apache.commons.hive.lang3shadedPattern>
- relocation>
- <relocation>
- <pattern>org.eclipse.jettypattern>
- <shadedPattern>org.eclipse.hive.jettyshadedPattern>
- relocation>
- <relocation>
- <pattern>org.mortbaypattern>
- <shadedPattern>org.mortbay.hiveshadedPattern>
- relocation>
- relocations>
- configuration>
- execution>
- executions>
- plugin>
- plugins>
- build>
- <repositories>
- <repository>
- <id>aliyunid>
-
- <name>spring-pluginname>
- <url>https://maven.aliyun.com/repository/spring-pluginurl>
- <releases>
- <enabled>trueenabled>
- releases>
- <snapshots>
- <enabled>falseenabled>
- snapshots>
- repository>
- repositories>
- project>