繁体   English   中英

如何为我的 GeoTools 项目找到正确的 Java 11 模块名称?

[英]How do I discover the correct Java 11 module names for my GeoTools project?

我正在尝试将我的应用程序转换为使用 Java 11 和 java 模块系统,但我很难发现要将哪些“需要”语句添加到我的 module-info.java。 我目前收到错误"The project was not built since its build path is incomplete. Cannot find the class file for org.locationtech.jts.geom.Envelope. Fix the build path then try building this project"

我搜索了https://github.com/geotools/geotools ,但我找不到关于哪些模块公开哪些包的任何提示。 例如,有一个模块“org.geotools.tile_client”,但在存储库中搜索该模块的结果为零(所以我假设 geotools 模块不是通过配置文件处理的?)。

遗憾的是,geotools Javadoc 也没有帮助,因为 geotools 尚未使用命名模块。

https://docs.geotools.org/stable/userguide/tutorial/quickstart/java11.html提到使用与我的 POM 中声明的相同的要求,但对于我的项目要求(gt-shapefile,gt-swing,gt- tile-client, gt-epsg-hsql, gt-grid) 这导致了错误:

The project was not built since its build path is incomplete. Cannot find the class file for org.opengis.referencing.crs.CoordinateReferenceSystem. Fix the build path then try building this project

通过深入了解 maven 依赖项,我发现了一些我现在也明确需要的依赖项。 这让我又犯了一些错误。

requires org.geotools.opengis;
requires org.geotools.referencing;
requires org.geotools.coverage;
requires org.geotools.main;
requires org.geotools.render;
requires org.geotools.epsg_hsql;
requires org.geotools.shapefile;
requires org.geotools.grid;
requires org.geotools.tile_client;
requires org.geotools.swing;
requires org.geotools.http;

但是,我确实找到了一个似乎不想工作的模块(gt-cql,gt-render 的依赖项)。 需要 org.geotools.cql 无法解析。

那么,正如顶部所问,我如何为我的 GeoTools 项目找到正确的 Java 11 模块名称? 是否有关于我应该需要哪个模块才能摆脱 org.locationtech.jts.geom.Envelope 问题的具体提示?

花了一段时间来解决这个问题,但是由于 jar --describe-module 命令,我得到了以下解决方案是否可以在不使用编译器标志的情况下在同一项目中混合 Java 8 和 Java 9 源代码? .

  1. 使用 mvn dependency:copy-dependencies 将 all.jar 文件复制到 target/dependency。

  2. 在 target/dependency 中,创建一个包含以下内容的文件“module-report.cmd”:

    > module-report.txt(对于 (%~dp0*.jar) 中的 %%f 执行 (jar --file=%%f --describe-module))

它只是在每个 jar 文件上运行“jar --file=... --describe-module”命令,将其输出到 module-report.txt。

  1. 运行module-report.cmd生成module-report.txt

文本文件的内容包含了所有的模块信息,包括包含的包,需要声明,一切。

使用该报告,我可以简单地搜索我无法访问的包,并轻松获取它们所在模块的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM