且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决将 Java 8 代码迁移到 Java 11 的依赖性和包问题

更新时间:2021-07-10 18:30:06

我今天遇到了问题 2.

I hit my head on the problem 2 today.

就我而言,避免导入就足够了

In my case, it was enough to avoid importing

<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>

这个工件/jar 包含相同的(与 XML 相关的)类,这些类与 Java 11 库冲突.这是因为我们收到错误包 x 可从多个模块访问".

This artifact/jar includes the same (XML related) classes, which *** with the Java 11 lib. This is because we get the error "package x is accessible from more than one module".

就我而言,我没有做任何其他事情.

In my case I did not do had to do anything more.

在您的情况下,(xxx 无法解析为类型")我猜您需要确保在编译时导入模块 java.xml .

In your case,("xxx cannot be resolved to a type") I'd guess you need to ensure to import the module java.xml , when compiling.

此页面建议

这可以通过在项目文件夹中创建一个文件 .mvn/jvm.config 并将选项放在那里来实现.这是一个简单的例子:

This is possible by creating a file .mvn/jvm.config in the project's folder and putting the options in there. Here's a simple example:

--add-modules java.xml.bind
--add-opens java.base/java.lang=ALL-UNNAMED
--illegal-access=deny

--add-modules 是在 Java 中包含模块的 javac 选项.

--add-modules is the javac option to include modules in Java.