记录一个Lombok,在jdk10下面无法启动的问题,lombok.javac.apt.LombokProcessor could not be initialized.

0x00 - 还是废话不多说了,标题佛性一点
lombok版本: 1.16.20
maven配置如下

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>10</source>
                <target>10</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok-maven-plugin</artifactId>
            <version>1.16.20.0</version>
        </plugin>
    </plugins>
</build>

IDEA 项目配置JDK版本为JDK10。

排坑的时候发现如果不配置maven-compiler-plugin,项目是可以启动的。
如果配置了maven-compiler-plugin,启动项目的时候,会抛出一个警告

Warning:(18, 8) java: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.sun.tools.javac.main.DelegatingJavaFileManager$DelegatingSJFM extends com.sun.tools.javac.main.DelegatingJavaFileManager implements javax.tools.StandardJavaFileManager
    at lombok.javac.apt.LombokFileObjects.getCompiler(LombokFileObjects.java:148)
    at lombok.javac.apt.InterceptingJavaFileManager.<init>(InterceptingJavaFileManager.java:40)
    at lombok.javac.apt.LombokProcessor.placePostCompileAndDontMakeForceRoundDummiesHook(LombokProcessor.java:165)
    at lombok.javac.apt.LombokProcessor.init(LombokProcessor.java:87)
    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)
    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.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:198)
    at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:453)
    at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:317)
    at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:244)
    at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:202)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1314)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:991)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1063)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:954)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:787)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:376)
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:308)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:137)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:235)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:844)

然后提示

Error:(27, 37) java: 找不到符号
  符号:   方法 builder()
  位置: 类 com.tooldin.cms.core.entity.TestEntity

对,没错,你发现的lombok,在编译器也不会抛红,就是运行不起来,什么找到不到符号,getXXX(),setXXX()找不到,都是类似的,抛出lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException

0x01 - 解决方案
方案一:
毕竟我算是在尝鲜,所以解决方案1就是,把JDK降回JDK1.8,据说JDK1.9,也会有问题。

方案二:
升级Lombok,stackoverflow大神说可以升级到1.16.21,但毕竟我此时此刻在http://mvnrepository.com/ 并没有,有需要的可以在https://www.projectlombok.org/download-edge下载,version: 1.16.21 (2018-05-04 11:49:59 UTC)。嗯,我发布这篇文章是2018-05-16 20:00:01,所以我先用方案一解决了。祝大家愉快~

阅读更多
文章标签: lombok jdk10 jdk1.9
个人分类: JAVA
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭