如何解决GeoMesa + HBase POM中的类路径问题

时间:2019-08-09 14:55:04

标签: maven hbase classpath pom.xml geomesa

org.geotools.data.DataStore.createSchema(sft)引发java.lang.NoSuchMethodError:org.apache.curator.shaded.com.google.common.collect.Maps.uniqueIndex(Ljava / lang / Iterable; Lcom / google / common / base / Function;)Lorg / apache / curator / shaded / com / google / common / collect / ImmutableMap;

我试图从geomesa-tutorial复制HBase的POM的一部分,但是阅读其他文章我意识到这可能与同一个库有2个不同版本有关,为了解决这个问题,我绝对是Maven的新手这是我一个人...

<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>
    <name>ScalabilityGeomesaHBase</name>
    <groupId>gr.tioahome.ee.geomesa.hbase.ntriples</groupId>
    <artifactId>ScalabilityGeomesaHBase</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <geomesa.version>2.3.1</geomesa.version>
        <gt.version>20.0</gt.version>
        <scala.abi.version>2.11</scala.abi.version>

        <!-- environment specific variables-->
        <hbase.version>1.4.10</hbase.version>
        <zookeeper.version>3.4.14</zookeeper.version>
        <hadoop.version>2.7.7</hadoop.version>
        <rdf4j.version>2.5.1</rdf4j.version>
    </properties>

    <repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Jave.net repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools</url>
        </repository>
        <!--
        <repository>
            <id>boundless</id>
            <name>Boundless Maven Repository</name>
            <url>https://repo.boundlessgeo.com/main</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </snapshots>
        </repository>
        -->
    </repositories>

    <dependencyManagement>
        <dependencies>
            <!-- https://mvnrepository.com/artifact/org.geotools/gt-epsg-wkt -->
            <dependency>
                <groupId>org.geotools</groupId>
                <artifactId>gt-epsg-wkt</artifactId>
                <version>${gt.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.locationtech.geomesa</groupId>
            <artifactId>geomesa_2.11</artifactId>
            <version>${geomesa.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.locationtech.geomesa</groupId>
            <artifactId>geomesa-utils_${scala.abi.version}</artifactId>
            <version>${geomesa.version}</version>
        </dependency>
        <dependency>
            <groupId>org.locationtech.geomesa</groupId>
            <artifactId>geomesa-index-api_${scala.abi.version}</artifactId>
            <version>${geomesa.version}</version>
        </dependency>

        <dependency>
            <groupId>org.locationtech.geomesa</groupId>
            <artifactId>geomesa-hbase-datastore_2.11</artifactId>
            <version>${geomesa.version}</version>
        </dependency>

        <dependency>
            <groupId>org.locationtech.geomesa</groupId>
            <artifactId>geomesa-hbase-spark-runtime_2.11</artifactId>
            <version>${geomesa.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-cli</groupId>
                    <artifactId>commons-cli</artifactId>
                </exclusion>
            </exclusions> 
        </dependency>
        <dependency>
            <groupId>org.locationtech.geomesa</groupId>
            <artifactId>geomesa-spark-sql_2.11</artifactId>
            <version>${geomesa.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-common</artifactId>
            <version>${hbase.version}</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.rdf4j</groupId>
            <artifactId>rdf4j-runtime</artifactId>
            <version>${rdf4j.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions> 
        </dependency>


        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-sql_2.11</artifactId>
            <version>2.4.0</version>
            <type>jar</type>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

1 个答案:

答案 0 :(得分:1)

我建议不包括geomesa-hbase-spark-runtime_2.11依赖项-这是一个有阴影的jar,可能会给您带来麻烦。您可以改为包含geomesa-hbase-spark_2.11,它是非阴影等效项。除此之外,对您的org.apache.curator的类路径中的jar进行grepping可能表明哪个jar出了问题。