记录一次lombok不生效的问题排查
使用lombok生成的getter setter方法,在maven编译时报错error: cannot find symbol
问题原因: 之前在做JSR-269(插件式注解) 相关测试的时候,修改了maven-compiler-plugin插件参数如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF8</encoding>
<proc>none</proc>
<fork>true</fork>
</configuration>
</plugin>
其中增加了<proc>none</proc>参数,该参数作用为
-
none - no annotation processing is performed.; only - only annotation processing is done, no compilation.
当指定none的时候,编译插件不会进行annotation processing也就是注解处理。由于lombok实现原理是基于JSR-269注解处理的方式实现的。故而导致lombok不生效导致编译报错。
另外以下情况注解也不会生效:
-
idea未开启annotation processing功能
