简体   繁体   English

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

[英]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 源代码? . .

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

  2. 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。

  1. Run module-report.cmd to generate module-report.txt运行module-report.cmd生成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.

相关问题 为什么我不能将geotools RasterToVectorFactory导入到我的项目中? - Why can i not import geotools RasterToVectorFactory to my project? 如何在 Android 中发现我的应用程序的内存使用情况? - How do I discover memory usage of my application in Android? 如何将GeoTools导入Intellij IDEA中的现有项目? - How do you import GeoTools into an existing project in Intellij IDEA? 我的GWT项目需要为java.io和java.nio继承哪个模块? - What module do I need to inherit for java.io and java.nio for my GWT project? 如何使用 GeoTools 创建具有纬度、经度和半径的圆? - How do I create a circle with latitude, longitude and radius with GeoTools? 如何在将升级到 Java 11 的 Java 8 项目中运行新功能? - How do I run new features in a Java 8 project that will be upgraded to Java 11? 如何在Java Applets中使用Geotools - How to use Geotools in Java Applets 如何在我的Android模块中添加java gradle子模块? - How do I add a java gradle submodule to my Android module? 如何在Web应用程序中设置登录模块? 在Java中? - How do i setup Login module in my web application? in Java? 我应该如何在Maven管理的Java项目中发现测试资源文件? - How should I discover test-resource files in a Maven-managed Java project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM