2015-10-26 133 views
2

使用lombok 1.16.6版本的lombok。從命令行構建(mvn clean install)時出現此錯誤:構建maven項目時獲取java.lang.ClassNotFoundException:lombok.javac.handlers.HandleHelper

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想法的錯誤。

回答

2

如在https://projectlombok.org/mavenrepo/處提到的,您應該使用provided範圍來定義對lombok的依賴關係。如下面的例子

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