中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

java10下編譯lombok注解代碼分享

發布時間:2020-10-15 00:57:16 來源:腳本之家 閱讀:202 作者:codecraft 欄目:編程語言


本文主要研究下在帶有lombok(1.16.20版本)注解的代碼在java10下的編譯問題。

問題

Fatal error compiling
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:564)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
  at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1086)
  at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:168)
  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
  ... 20 more
Caused by: org.codehaus.plexus.compiler.CompilerException: java.lang.ExceptionInInitializerError
  at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:173)
  at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
  at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1075)
  ... 23 more
Caused by: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
  at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:158)
  at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
  at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
  at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
  ... 25 more
Caused by: java.lang.ExceptionInInitializerError
  at lombok.javac.handlers.HandleGetter.<clinit>(HandleGetter.java:303)
  at java.base/java.lang.Class.forName0(Native Method)
  at java.base/java.lang.Class.forName(Class.java:374)
  at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:111)
  at lombok.javac.HandlerLibrary.loadAnnotationHandlers(HandlerLibrary.java:171)
  at lombok.javac.HandlerLibrary.load(HandlerLibrary.java:156)
  at lombok.javac.JavacTransformer.<init>(JavacTransformer.java:44)
  at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:89)
  at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
  at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:140)
  at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:69)
  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:674)
  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:771)
  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:866)
  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.access$2100(JavacProcessingEnvironment.java:110)
  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1202)
  at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1311)
  at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1250)
  at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:928)
  at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
  at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
  ... 28 more
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags
  at java.base/java.lang.ClassLoader.findClass(ClassLoader.java:711)
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
  at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:422)
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
  at java.base/java.lang.Class.forName0(Native Method)
  at java.base/java.lang.Class.forName(Class.java:291)
  at lombok.javac.JavacTreeMaker$SchroedingerType.getFieldCached(JavacTreeMaker.java:156)
  at lombok.javac.JavacTreeMaker$TypeTag.typeTag(JavacTreeMaker.java:245)
  at lombok.javac.Javac.<clinit>(Javac.java:155)
  ... 49 more

解決

這是當前1.16.20版本的問題,通過升級到最新snapshot版本1.16.21即可搞定,1.16.21的版本更新描述如下:

version: 1.16.21 (2018-03-29 11:54:42 UTC)
v1.16.20 is the latest stable release of Project Lombok.
PLATFORM: Fix for using lombok together with JDK9's new module-info.java feature. Issue #985
PLATFORM: Some initial work on supporting JDK10.
BUGFIX: Potential fix for Netbeans < 9. Issue #1555
PROMOTION: var has been promoted from experimental to the main package with no changes. The 'old' experimental one is still around but is deprecated, and is an alias for the new main package one. var documentation.
OLD-CRUFT: lombok.experimental.Builder and lombok.experimental.Value are deprecated remnants of when these features were still in experimental. They are now removed entirely. If your project is dependent on an older version of lombok which still has those; fret not, lombok still processes these annotations. It just no longer includes them in the jar.

本地安裝

mvn install:install-file -Dfile=lombok-1.16.21.jar -DgroupId=org.lombokproject -DartifactId=lombok -Dversion=1.16.21 -Dpackaging=jar

更新依賴

<dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.16.21</version>
      <scope>provided</scope>
    </dependency>

這樣就大功告成了,如果大家在測試的時候還有任何疑問,可以在下方留言區討論,感謝大家對億速云的支持。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

金阳县| 左云县| 望谟县| 北川| 孟村| 肥乡县| 射洪县| 广南县| 乐陵市| 聂荣县| 湖州市| 商南县| 棋牌| 洛宁县| 若羌县| 太康县| 嘉峪关市| 太谷县| 托克托县| 上高县| 昆山市| 梓潼县| 临湘市| 江津市| 平和县| 清水河县| 吴江市| 隆德县| 平度市| 岱山县| 阿荣旗| 泸西县| 阿拉善右旗| 遂宁市| 屏东县| 阆中市| 甘孜| 黑龙江省| 商南县| 忻州市| 江西省|