【问题标题】:Not able to locate FactoryRegistry class when using GeoTools使用 GeoTools 时无法找到 FactoryRegistry 类
【发布时间】:2016-03-17 10:40:46
【问题描述】:

我正在尝试使用 GeoTools 库加载和解析 shapefile。但是,当我尝试加载文件时,导致以下调用是 org.geotools.factory.FactoryRegistry 的依赖失败:

DataStore newStore = DataStoreFinder.getDataStore(connect);

错误:

org/geotools/factory/FactoryRegistry
java.lang.NoClassDefFoundError: org/geotools/factory/FactoryRegistry

我在 gradle 中包含了以下依赖项:

compile files ('libs/geotools/gt-opengis-14.2.jar')
compile files ('libs/geotools/gt-api-14.2.jar')
compile files ('libs/geotools/gt-shapefile-14.2.jar')
compile files ('libs/geotools/gt-cql-14.2.jar')
compile files ('libs/geotools/gt-main-14.2.jar')
compile files ('libs/geotools/gt-referencing-14.2.jar')
compile files ('libs/geotools/gt-epsg-hsql-14.2.jar')

我不确定它们是否都需要,但它们都没有缺失的类。我还缺少其他依赖项吗?该课程记录在here

【问题讨论】:

    标签: java shapefile geotools


    【解决方案1】:

    这个问题的简单答案是使用 Maven 来管理你的依赖,然后它会自动为你拉入gt-metadata 并解决你的问题。

    如果您必须手动管理您的依赖关系,那么我写了一个blog post,描述了如何使用oops 在 GeoTools jar 中搜索一个类。

    【讨论】:

    • 谢谢。我添加了gt-metadata。这解决了这个问题,但现在我得到了其他类的其他类似错误。我知道使用 Maven(或 Gradle)来管理依赖项可以解决这个问题。但是在 repo 中找不到这些依赖项。我看到其他人报告了同样的问题,但提出的解决方案都不适合我。
    • 你想连接什么样的商店?
    • 试过不少。最新的是download.osgeo.org/webdav/geotools。但这似乎是不一致的。不同的依赖项在不同的时间被报告丢失。现在缺少的是Could not find jai_core.jar (javax.media:jai_core:1.1.3)
    • 已修复。 Gradle 正在从 mavenCentral 寻找 jai_core。在存储库列表中将 mavenCentral 移动到 osgeo 之后修复它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多