我正在使用Maven 3.5.0和JDK 9 build 171。当我尝试编译我的项目时,出现了异常:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project admin: Fatal error compiling: ja-va.lang.NoClassDefFoundError: com/sun/tools/javac/file/BaseFileObject: com.sun.tools.javac.file.BaseFileObject
我已经按照建议在MAVEN_OPTS中添加了标志,但没有成功:
--add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
有什么建议吗?
--permit-illegal-access
或者最近增加的版本--illegal-access=warn
有帮助吗? - Naman-X
选项运行mvn
进行调试,查看 mvn 编译器插件所使用的模块版本是什么,这些模块包括:org.codehaus.plexus:plexus-compiler-api
、org.codehaus.plexus:plexus-compiler-manager
和org.codehaus.plexus:plexus-compiler-javac:jar
。版本应该是 2.8.1。 - Anton Krosnev