前言:这是一个困扰了我很多天的问题。CSDN上没有回答解决了我的问题。

安装lombok的两种方法:
1.File->Settings->Plugins->搜索lombok->install
2.File->Settings->Plugins->Install plugin from disk

在pom.xml中加入

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

完了记得File->Settings->Build, Execution, Deployment->Complier->Annotation Processors
然后重启IDEA

据网上一般流程,这样就好了。

然而我Maven的Dependencies一直飘红,
终于在stackoverflow找到一个回答,我在pom.xml中加了这个

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>${maven.plugin.compiler.version}</version>
  <configuration>
    <compilerVersion>${java.version}</compilerVersion>
    <source>${java.version}</source>
    <target>${java.version}</target>
    <annotationProcessors>
      <annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
    </annotationProcessors>
  </configuration>
</plugin>

原问题链接:
https://stackoverflow.com/questions/24006937/lombok-annotations-do-not-compile-under-intellij-idea?r=SearchResults
原回答:在这里插入图片描述

Install lombok plugin
Settings -> Compiler -> Annotation Processors -> Enable annotation processing: checked (default configuration)
Settings -> Compiler -> Annotation Processors -> Annotation Processors add "lombok.launch.AnnotationProcessorHider$AnnotationProcessor"
Also if you are using maven add to maven-compiler-plugin configuration -> annotationProcessors -> annotationProcessor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐