使用 GeoTools 时无法找到 FactoryRegistry class

Not able to locate FactoryRegistry class when using GeoTools

我正在尝试使用 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')

我不确定是否需要所有这些,但是 none 其中缺少 class。我还缺少其他依赖项吗? class 记录在案 here

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

如果您必须手动管理依赖项,那么我写了一个 blog post that describes how to use oops 来搜索 GeoTools jar 以查找 class。