[英]How do I discover the correct Java 11 module names for my GeoTools project?
I am trying to convert my application to use Java 11 and the java module system, but am having difficulty discovering which "requires" statements to add to my module-info.java.我正在尝试将我的应用程序转换为使用 Java 11 和 java 模块系统,但我很难发现要将哪些“需要”语句添加到我的 module-info.java。 I am currently getting the error
"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"
.我目前收到错误
"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"
。
I have searched through https://github.com/geotools/geotools , but I cannot find any hints regarding which modules expose which packages.我搜索了https://github.com/geotools/geotools ,但我找不到关于哪些模块公开哪些包的任何提示。 For example there is a module "org.geotools.tile_client", but searching that in the repository gets zero hits (so I assume the geotools modules are not handled via config files?).
例如,有一个模块“org.geotools.tile_client”,但在存储库中搜索该模块的结果为零(所以我假设 geotools 模块不是通过配置文件处理的?)。
The geotools Javadoc is unfortunately also not helpful, as geotools is not yet using named modules.遗憾的是,geotools Javadoc 也没有帮助,因为 geotools 尚未使用命名模块。
https://docs.geotools.org/stable/userguide/tutorial/quickstart/java11.html mentioned using the same requires as the ones declared in my POM, but for my project requireing (gt-shapefile, gt-swing, gt-tile-client, gt-epsg-hsql, gt-grid) this resulted in the error: 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
Through digging down through the maven dependencies, I found a few more which I now explicitely require too.通过深入了解 maven 依赖项,我发现了一些我现在也明确需要的依赖项。 This brought me past a few more errors.
这让我又犯了一些错误。
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;
However, I did find a module which doesnt seem to want to work (gt-cql, dependency of gt-render).但是,我确实找到了一个似乎不想工作的模块(gt-cql,gt-render 的依赖项)。 requires org.geotools.cql cannot be resolved.
需要 org.geotools.cql 无法解析。
So, as asked at the top, how do I discover the correct Java 11 module names for my GeoTools project?那么,正如顶部所问,我如何为我的 GeoTools 项目找到正确的 Java 11 模块名称? And is there a specific hint as to which module I should require in order to get rid of the org.locationtech.jts.geom.Envelope problem?
是否有关于我应该需要哪个模块才能摆脱 org.locationtech.jts.geom.Envelope 问题的具体提示?
Took a while to come to this, but I have come to the following solution thanks to the jar --describe-module command from Is it possible to mix Java 8 and Java 9 source code in the same project without using compiler flags?花了一段时间来解决这个问题,但是由于 jar --describe-module 命令,我得到了以下解决方案是否可以在不使用编译器标志的情况下在同一项目中混合 Java 8 和 Java 9 源代码? .
.
Using mvn dependency:copy-dependencies copies all.jar files to target/dependency.使用 mvn dependency:copy-dependencies 将 all.jar 文件复制到 target/dependency。
In target/dependency, create a file "module-report.cmd" with the following content.:在 target/dependency 中,创建一个包含以下内容的文件“module-report.cmd”:
> module-report.txt ( for %%f in (%~dp0*.jar) do ( jar --file=%%f --describe-module ) ) > module-report.txt(对于 (%~dp0*.jar) 中的 %%f 执行 (jar --file=%%f --describe-module))
Its just running the "jar --file=... --describe-module" command on every jar file, outputting it to module-report.txt.它只是在每个 jar 文件上运行“jar --file=... --describe-module”命令,将其输出到 module-report.txt。
The contents of the text file contain all of the module information, including contained packages, requires declarations, everything.文本文件的内容包含了所有的模块信息,包括包含的包,需要声明,一切。
Using that report I could then simply search for the packages I couldn't access and easily get the name of the module they were contained in.使用该报告,我可以简单地搜索我无法访问的包,并轻松获取它们所在模块的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.