最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Hbase、elasticsearch整合中jar包沖突的問(wèn)題解決

 更新時(shí)間:2017年12月02日 14:22:35   作者:止魚  
本篇文章主要介紹了Hbase、elasticsearch整合中jar包沖突的問(wèn)題解決,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

問(wèn)題背景

再數(shù)據(jù)平臺(tái)中,項(xiàng)目搭建需要使用es和HBASE搭建數(shù)據(jù)查詢接口,整合的過(guò)程中出現(xiàn)jar包沖突的bug :com.google.common.base.Stopwatch.()V from class org.apache.hadoop.hbase.zookeeper.MetaTableLocator

org.apache.hadoop.hbase.DoNotRetryIOException: java.lang.IllegalAccessError: tried to access method com.google.common.base.Stopwatch.<init>()V from class org.apache.hadoop.hbase.zookeeper.MetaTableLocator
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.translateException(RpcRetryingCaller.java:239)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:150)
    ...
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.base.Stopwatch.<init>()V from class org.apache.hadoop.hbase.zookeeper.MetaTableLocator
    at org.apache.hadoop.hbase.zookeeper.MetaTableLocator.blockUntil
    ...
    at org.apache.hadoop.hbase.client.RegionServerCallable.prepare(RegionServerCallable.java:75)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:134)
    ... 45 more

解決辦法

經(jīng)排查,確認(rèn)是因?yàn)?com.google.guava 這個(gè)包引起的沖突。es依賴于18及以上版本,而HBASE只支持16及以上版本。而guava這個(gè)包從17開始內(nèi)部發(fā)生變化,方法發(fā)生改變,所以18并不會(huì)向下兼容16版本。在項(xiàng)目運(yùn)行的過(guò)程中,如果同時(shí)引入16、18版本,es及hbase的調(diào)用過(guò)程會(huì)發(fā)生混亂。那么接下來(lái)就好辦了,我們可以重新打包,將guava18打入es內(nèi)部,再在pom文件中顯示引用guava16版本的包。這樣,es調(diào)用包內(nèi)部打入的guava18,而hbase調(diào)用外部的guava16。

重新打包

新建maven工程,在pom文件中進(jìn)行如下配置:

<?xml version="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.0</modelVersion>

  <!--
    this maven project is aim to fix the jar comflic in hbase & elasticsearch.
    in es, required guava 18+ or up. but in hbase you should use guava 16- or blow.

    cd the project directory and run 'sh ./cleanbuild.sh',you will get a new-self jar.
    then, adjust your project pom.xml whth:
    <dependency>
      <groupId>douguo.shaded.elasticsearch</groupId>
      <artifactId>douguo_shaded_elasticsearch</artifactId>
      <version>1.0-SNAPSHOT</version>
      <exclusions>
        <exclusion>
          <groupId>org.elasticsearch</groupId>
          <artifactId>elasticsearch</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    finally, your jar comflic will be fixed.

    @date:2017-11-30
    @author:zhangjianfei
    @since:douguo.shaded.elasticsearch-1.0.0
  -->
  <groupId>douguo.shaded.elasticsearch</groupId>
  <artifactId>douguo_shaded_elasticsearch</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <elasticsearch.version>2.4.1</elasticsearch.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>${elasticsearch.version}</version>
    </dependency>
    <dependency>
      <groupId>org.elasticsearch.plugin</groupId>
      <artifactId>shield</artifactId>
      <version>${elasticsearch.version}</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.1</version>
        <configuration>
          <createDependencyReducedPom>false</createDependencyReducedPom>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <relocations>
                <relocation>
                  <pattern>com.google.guava</pattern>
                  <shadedPattern>douguo.shaded.elasticsearch.guava</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.joda</pattern>
                  <shadedPattern>douguo.shaded.elasticsearch.joda</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.common</pattern>
                  <shadedPattern>douguo.shaded.elasticsearch.common</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.thirdparty</pattern>
                  <shadedPattern>douguo.shaded.elasticsearch.thirdparty</shadedPattern>
                </relocation>
              </relocations>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" />
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>elasticsearch-releases</id>
      <url>http://maven.elasticsearch.org/releases</url>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

</project>

將org.joda等4個(gè)可能有沖突的jar包通過(guò)maven-shade-plugin插件遷移后重新打個(gè)jar包從而使得在引入這個(gè)jar包時(shí)能夠使用該jar包自己的依賴而不是使用外部依賴。這里需要注意的是,需要將com.google.common等4個(gè)包全部重新遷移,否則會(huì)出現(xiàn)java.lang.IllegalAccessError: tried to access method com.google.common.base的錯(cuò)誤

項(xiàng)目打包

mvn clean install

新的依賴包會(huì)在.m2 maven倉(cāng)庫(kù)中,如果公司搭建了倉(cāng)庫(kù)的話,需要上傳jar包。如果直接運(yùn)行jar包的話,記得重新編譯項(xiàng)目,并替換lib目錄

項(xiàng)目載入新包

只需要在pom文件中配置:

<!-- douguo.shaded.elasticsearch -->
<dependency>
  <groupId>douguo.shaded.elasticsearch</groupId>
  <artifactId>douguo_shaded_elasticsearch</artifactId>
  <version>1.0-SNAPSHOT</version>
  <exclusions>
    <exclusion>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
    </exclusion>
  </exclusions>
</dependency>


<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<!-- this guava is only used in habse
   in es, 18.0+ is required, but hbase only supported 16.0 or blow.
   clean as install douguo.shaded.elasticsearch -->
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>16.0</version>
</dependency>

這樣,guava18包就在douguo.shaded.elasticsearch下,es會(huì)優(yōu)先調(diào)用。而外部配置的guava16就會(huì)被HBASE調(diào)用。2個(gè)版本的jar包互相獨(dú)立存在!

到此,問(wèn)題就解決了!

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • MyBatis常用標(biāo)簽以及使用技巧總結(jié)

    MyBatis常用標(biāo)簽以及使用技巧總結(jié)

    在我們的學(xué)習(xí)過(guò)程中,我們經(jīng)常使用到mybatis,這篇文章主要給大家介紹了關(guān)于MyBatis常用標(biāo)簽以及使用技巧的相關(guān)資料,需要的朋友可以參考下
    2021-05-05
  • 關(guān)于thymeleaf判斷對(duì)象是否為空的相關(guān)邏輯處理

    關(guān)于thymeleaf判斷對(duì)象是否為空的相關(guān)邏輯處理

    這篇文章主要介紹了關(guān)于thymeleaf判斷對(duì)象是否為空的相關(guān)邏輯處理,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • IDEA中設(shè)置背景顏色的步驟

    IDEA中設(shè)置背景顏色的步驟

    在IntelliJ IDEA中,用戶可以通過(guò)訪問(wèn)【Settings】或【Preferences】菜單,進(jìn)入【Editor】>【ColorScheme】選項(xiàng)來(lái)選擇和調(diào)整編輯區(qū)域的顏色方案,此外,通過(guò)【Appearance & Behavior】>【Appearance】選項(xiàng)
    2024-09-09
  • SpringMVC中@Valid不起效BindingResult讀取不到Error信息

    SpringMVC中@Valid不起效BindingResult讀取不到Error信息

    在寫SpringMVC項(xiàng)目時(shí),由于要對(duì)表單數(shù)據(jù)進(jìn)行校驗(yàn),需要使用@Valid進(jìn)行校驗(yàn),但是在進(jìn)行數(shù)據(jù)校驗(yàn)時(shí),BindingResult對(duì)象無(wú)法攔截非法表單數(shù)據(jù),result.hasErrors()無(wú)論怎么輸入都會(huì)返回false,本文詳細(xì)的介紹一下解決方法
    2021-09-09
  • spring boot(一)之入門篇

    spring boot(一)之入門篇

    Spring Boot是由Pivotal團(tuán)隊(duì)提供的全新框架,其設(shè)計(jì)目的是用來(lái)簡(jiǎn)化新Spring應(yīng)用的初始搭建以及開發(fā)過(guò)程。接下來(lái)通過(guò)本文給大家介紹spring boot入門知識(shí),需要的朋友參考下吧
    2017-05-05
  • java父類和子類初始化順序的深入理解

    java父類和子類初始化順序的深入理解

    本篇文章是對(duì)java父類和子類初始化順序進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • 淺談SpringCloud feign的http請(qǐng)求組件優(yōu)化方案

    淺談SpringCloud feign的http請(qǐng)求組件優(yōu)化方案

    這篇文章主要介紹了淺談SpringCloud feign的http請(qǐng)求組件優(yōu)化方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-02-02
  • 記一次用IDEA打開java項(xiàng)目后不能運(yùn)行的解決方法

    記一次用IDEA打開java項(xiàng)目后不能運(yùn)行的解決方法

    這篇文章主要介紹了記一次用IDEA打開java項(xiàng)目后不能運(yùn)行的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-03-03
  • SpringBoot + openFeign實(shí)現(xiàn)遠(yuǎn)程接口調(diào)用的過(guò)程

    SpringBoot + openFeign實(shí)現(xiàn)遠(yuǎn)程接口調(diào)用的過(guò)程

    現(xiàn)在的微服務(wù)項(xiàng)目不少都使用的是springboot+spring cloud構(gòu)建的項(xiàng)目,微服務(wù)之間的調(diào)用都離不開feign來(lái)進(jìn)行遠(yuǎn)程調(diào)用,這篇文章主要介紹了SpringBoot + openFeign實(shí)現(xiàn)遠(yuǎn)程接口調(diào)用,需要的朋友可以參考下
    2022-11-11
  • 教你開發(fā)腳手架集成Spring?Boot?Actuator監(jiān)控的詳細(xì)過(guò)程

    教你開發(fā)腳手架集成Spring?Boot?Actuator監(jiān)控的詳細(xì)過(guò)程

    這篇文章主要介紹了開發(fā)腳手架集成Spring?Boot?Actuator監(jiān)控的詳細(xì)過(guò)程,集成包括引入依賴配置文件及訪問(wèn)驗(yàn)證的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05

最新評(píng)論

遵义县| 东平县| 电白县| 海门市| 宾川县| 馆陶县| 千阳县| 平安县| 江川县| 黄梅县| 海门市| 南溪县| 瓮安县| 宜丰县| 临西县| 封丘县| 盐山县| 胶州市| 洛浦县| 万年县| 永寿县| 仪征市| 宁海县| 渑池县| 温泉县| 大同市| 博罗县| 淅川县| 双桥区| 澜沧| 建阳市| 郓城县| 九寨沟县| 清涧县| 麻栗坡县| 湟中县| 天全县| 东源县| 平邑县| 醴陵市| 四子王旗|