42

I am using Lombok’s @Data annotation to create the basic functionality of my POJOs. When I try to use these generated methods, IntelliJ highlights these as errors (Cannot resolve method ‘getFoo()’) and seems to be unable to find them. They do however exist, as I am able to run code using these methods without any trouble.

I made sure to enable annotation processing, so that shouldn’t cause any problems.

How can I get IntelliJ to find the methods and stop wrongly marking them as errors?

guest
  • 423
  • 1
  • 4
  • 5
  • try refeshing the project ,also check if you can added lombok dependency – mohit sharma Oct 20 '16 at 10:12
  • 1
    Does this answer your question? [Can't compile project when I'm using Lombok under IntelliJ IDEA](https://stackoverflow.com/questions/9424364/cant-compile-project-when-im-using-lombok-under-intellij-idea) – Valeriy K. Jan 30 '20 at 09:21

2 Answers2

69

You will also need the lombok plugin.

Alpar
  • 2,807
  • 23
  • 16
12

Check if you have added lombok dependency Maven:

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

Gradle:

// https://mvnrepository.com/artifact/org.projectlombok/lombok
provided group: 'org.projectlombok', name: 'lombok', version: '1.16.18'

Install Lombok plugin

Preferences > Plugins > Browse Repositories >

Search for "Lombok" and install the plugin

Then you can import

import lombok.Data;
Abdullah Ahçı
  • 786
  • 10
  • 19