Itext7 Jars未正确加载到JavaFX项目中。

huangapple go评论60阅读模式
英文:

Itext7 Jars not loading in properly to javafx project

问题

我在我的pom.xml文件中有这个依赖项

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itext7-core</artifactId>
    <version>7.1.18</version>
    <type>pom</type>
</dependency>

而在我的module-info.java文件中,我有以下内容

requires transitive kernel;


这会产生以下警告,"自动模块的名称 'kernel' 不稳定,它是从模块的文件名派生的。"

我该怎么做才能摆脱这个警告?

我尝试将其更改为

requires transitive com.itextpdf.kernel;


但然后我收到以下错误消息,"com.itextpdf.kernel 无法解析为模块"

我尝试了一堆类似的代码行,但都没有起作用。我该如何更改代码以消除错误/警告?
英文:

I've got this dependency in my pom.xml

    &lt;dependency&gt;
        &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
        &lt;artifactId&gt;itext7-core&lt;/artifactId&gt;
        &lt;version&gt;7.1.18&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
    &lt;/dependency&gt;

And in my module-info.java file I have the following

requires transitive kernel; 

which produces the following warning, "Name of automatic module 'kernel' is unstable, it is derived from the module's file name."

What can I do to get rid of this warning?

I tried changing it to

requires transitive com.itextpdf.kernel;

but then I get the following error, "com.itextpdf.kernel cannot be resolved to a module"

I tried a bunch of other similar lines of code but nothing worked. What can I change the code to in order to remove the error/warning?

答案1

得分: 1

itext7目前不是模块化的。

您可以联系开发人员并要求他们使其模块化。

与此同时,像这样复杂的非模块化系统在模块化项目中使用起来很困难。即使您通过自动模块系统或类似moditect的方式添加模块信息使其工作,也几乎摧毁了项目模块化的任何潜在好处,并且以一种它从未设计过的方式运行软件。

因此,请将您的项目设置为非模块化:

  • 从项目中删除module-info.java
  • 使用以下方法之一引入JavaFX模块:
    • 使用VM参数将它们添加到模块路径中,或者
    • 使用包括它们的JRE/JDK分发版本,例如BellSoft Liberica的“Full JDK”或Azul Zulu的“JDK FX”。

有关在非模块化JavaFX项目中的更多操作说明,请参阅openjfx.io的入门文档。

我不确定“非模块化”是什么意思,但如果itext7网站提供了要添加到pom.xml的Maven依赖项,那怎么可能是真的呢?

非模块化意味着您的项目中没有定义module-info.java

请阅读理解模块以及我在openjfx.io上链接的文档,以了解JavaFX模块系统的基础知识以及如何在JavaFX应用程序中使用它。

Maven模块Java平台模块是不同的东西,它们具有相同的名称“模块”,但一个是构建时的定义,另一个是运行时的定义。此外,Maven依赖项只是一个依赖项,它不是一个Maven模块或Java平台模块。尽管您可以依赖于由Maven模块构建的构件,并且如果它们与之兼容,还可以通过Java平台模块系统执行这些构件。

itext7没有构建为Java平台模块。该软件没有module-info.java,并且也没有为自身定义自动模块名称。鉴于您的软件依赖于非模块化的软件,我认为您的软件也不应该是模块化的。

英文:

itext7 currently isn't modular.

You can contact the developers and ask them to make it modular.

In the meantime, complex, non-modular systems like this are difficult to use from a modular project. Even if you get that to work via the automatic module system or hacking in module info via something like moditect, it pretty much destroys any potential benefit of the project being modular, and it runs the software in a way it was never designed to work.

So, make your project non-modular:

  • remove the module-info.java from your project.
  • source the javafx modules using either:
    • VM arguments pointing adding them to the module path OR
    • from a JRE/JDK distribution that includes them, e.g. BellSoft Liberica "Full JDK" or Azul Zulu "JDK FX".

For further instructions on working with non-modular JavaFX projects, see the getting started documentation at: openjfx.io.

> I am not sure what "not modular" means but how can that be true if the itext7 website gives maven dependencies to incorporate into your pom.xml?

Non-modular means that you don't define a module-info.java in your project.

Read understanding modules and the documentation I linked at openjfx.io to understand the basics of the JavaFX module system and how it can be used in a JavaFX application.

Maven modules and Java Platform modules are different things, they have the same name "module" but one is a build-time definition and the other is a runtime definition. Also, a maven dependency is just a dependency, it is not a Maven module or a Java Platform module. Though you can depend on artifacts built by a maven module and you can execute those artifacts through the Java Platform module system (if they are compatible with it).

itext7 is not built as a Java Platform module. The software has no module-info.java and it does not define an automatic module name for itself either. Given that your software is depending on non-modular software, your software should not be modular either (in my opinion).

huangapple
  • 本文由 发表于 2023年1月9日 09:25:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75052446.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定