idea报错:不存在的方法 /java:找不到符号

在新版idea使用时,引入Lombok依赖后,一直报错找不到对应符号。

java 复制代码
@Data
public class Test {
    private String username;
    private String password;
}

使用时报错:找不到setUsername,getUsername。

处理方法: 更新idea到>=3.2.2

本人版本idea版本3.2.1因此触发了这个bug;

参考链接 youtrack.jetbrains.com/issue/IDEA-...

当然如果你更新到3.2.2后还是触发了这个bug。 可以通过如下方案来临时解决这个问题: 方案1:

  1. 在idea的设置中,File -> Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors开启允许注解进程的运行。(enable annotation processing);

2.(可选) 顺带将生成的资源路径改为module content root 方案2:

  1. 进入pom.xml文件,将Lombok相关的使用<version>${lombok.version}</version>替代。(包括 dependencies、dependanManager、maven-compiler-plugin
xml 复制代码
<project>
    
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
相关推荐
JAVA面经实录9174 天前
Java开发工程基础完整手册(企业实战完整版)
java·开发语言·git·ci/cd·svn·github·intellij idea
掉头发的王富贵7 天前
如何自己开发一个IDEA插件
后端·intellij idea
月明水寒10 天前
IDEA2026.1 vue文件报错
前端·javascript·vue.js·intellij-idea·idea·intellij idea
·你好·11 天前
mybatis sql 日志问号替换
intellij idea·idea插件
殷紫川13 天前
IDEA Claude Code 插件封神指南:让 AI 成为你的结对编程伙伴
后端·ai编程·intellij idea
golang学习记14 天前
☕️➡️🚀 Java 一键转 Kotlin?VS Code 这个新插件太香了!
intellij idea·visual studio code
用户65317803136918 天前
吃透IDEA Debug:从基础到高级,开发必备调试技巧
intellij idea
golang学习记19 天前
IDEA官宣:终于可以爽用Junie CLI了!
intellij idea
其实是白羊20 天前
我用 Vibe Coding 搓了一个 IDEA 插件,复制URI 再也不用手动拼了
后端·intellij idea
殷紫川1 个月前
IDEA 集成 GitHub Copilot 指南:解锁 10 倍编码效率的全链路实战
github·intellij idea·github copilot