使用lombok 1.16.6版本的lombok。从命令行构建(mvn clean install)时出现此错误:
java.lang.ClassNotFoundException: lombok.javac.handlers.HandleHelper
[ERROR] at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:114)
[ERROR] at lombok.javac.HandlerLibrary.loadAnnotationHandlers(HandlerLibrary.java:170)
[ERROR] at lombok.javac.HandlerLibrary.load(HandlerLibrary.java:155)
[ERROR] at lombok.javac.JavacTransformer.<init>(JavacTransformer.java:43)
[ERROR] at lombok.javac.apt.Processor.init(Processor.java:86)
[ERROR] at lombok.core.AnnotationProcessor$JavacDescriptor.want(AnnotationProcessor.java:87)
[ERROR] at lombok.core.AnnotationProcessor.init(AnnotationProcessor.java:141)
[ERROR] at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.init(AnnotationProcessor.java:53)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment$ProcessorState.<init>(JavacProcessingEnvironment.java:500)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.next(JavacProcessingEnvironment.java:597)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:690)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
[ERROR] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:523)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:381)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:370)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:361)
[ERROR] at com.sun.tools.javac.Main.compile(Main.java:56)
[ERROR] at com.sun.tools.javac.Main.main(Main.java:42)
[ERROR] Caused by: java.lang.ClassNotFoundException: lombok.javac.handlers.HandleHelper
[ERROR] at java.lang.ClassLoader.findClass(ClassLoader.java:530)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[ERROR] at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:366)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[ERROR] at java.lang.Class.forName0(Native Method)
[ERROR] at java.lang.Class.forName(Class.java:348)
[ERROR] at lombok.core.SpiLoadUtil$1$1.next(SpiLoadUtil.java:111)
$ mvn -v
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: /usr/share/maven
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-66-generic", arch: "amd64", family: "unix"
它没有给出Intellij想法的任何错误。
答案 0 :(得分:4)
如https://projectlombok.org/mavenrepo/所述,您应该定义lombok
范围与provided
的依赖关系。如下例
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.6</version>
<scope>provided</scope>
</dependency>
</dependencies>