Maven包错误

Maven package error

我正在做一个需要 geotools 依赖项的项目。在我收到以下错误之前:

Exception in thread "main" java.lang.IllegalStateException: cannot initilize transformation: Authority "EPSG" is unknown or doesn't match the supplied hints. Maybe it is defined in an unreachable JAR file?
        at com.test.geometricutils.TransformProjection.initializeTransformer(TransformProjection.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:879)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain(SparkSubmit.scala:197)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:227)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:136)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: org.opengis.referencing.NoSuchAuthorityCodeException: Authority "EPSG" is unknown or doesn't match the supplied hints. Maybe it is defined in an unreachable JAR file?
        at org.geotools.referencing.factory.ManyAuthoritiesFactory.noSuchAuthority(ManyAuthoritiesFactory.java:488)
        at org.geotools.referencing.factory.ManyAuthoritiesFactory.getAuthorityFactory(ManyAuthoritiesFactory.java:466)
        at org.geotools.referencing.factory.ManyAuthoritiesFactory.getCRSAuthorityFactory(ManyAuthoritiesFactory.java:547)
        at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:799)
        at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:730)
        at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
        at org.geotools.referencing.CRS.decode(CRS.java:488)
        at org.geotools.referencing.CRS.decode(CRS.java:416)
        at 

已通过以下依赖解决:

 <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>2.11.0</version>
 </dependency>

并且项目构建成功,没有任何错误。现在,我正在尝试使用此命令将我的项目打包到一个 jar 中:

mvn assembly:assembly -DdescriptorId=jar-with-dependencies

但我又收到同样的错误信息。我不知道为什么它在 intellij 中是 运行 作为项目,但在 运行 包命令之后不是

如有任何帮助或提示,我们将不胜感激。

首先,您需要一个 EPSG 工厂(而不是 xerces)来解决您的第一个问题 - 请参阅 GeoTools FAQ 了解更多详细信息。

其次,在组装 fat(或 uber)jar 时,您需要特别注意 GeoTools FAQ 中描述的 spi 控制文件。

您可以在 Maven 存储库中检查您的 geotools 版本。并且您应该确保所有 geotools 的版本都适用,尤其是 gt-epsg-hsql。