【发布时间】:2021-06-30 23:34:47
【问题描述】:
我已经 10 年没有开发 Java,需要快速编译一个用 Java 8 特性编写的plugin project。我下载了latest JDK (AdoptOpenJDK 16) 并将其安装在我的 MacOS 开发机器上。
查看项目的POM文件,我看到了这两个设置:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
而read that these settings 会提示编译器代码是使用 Java 8 功能编写的,并且编译后的类需要与 1.8 JVM 兼容。
我关注了the developer instructions,但遇到了错误:
在初始构建时,以下错误将停止构建:
[ERROR] import: Entry[import from realm ClassRealm[project>org.github.flytreeleft:nexus3-keycloak-plugin:0.5.0-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : begin 0, end 3, length 2
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
Similar people encountered the same issue 在其他项目上。最终我使用了was suggested to skip the maven Enforcer 的解决方法来解决这个错误。
重建后,项目将失败,并在各种文件中出现大约 90 个编译错误。这些消息会说类似于:
String cannot be resolved to a type
这让我找到了this SO questions that had a similar error ...但没有好的答案。
如何构建这个项目?
【问题讨论】:
-
也许分析一下代码中真正存在的问题会更好。
标签: java macos maven visual-studio-code adoptopenjdk