I recently upgraded to Eclipse 2021-03 version (due to some plugin issues with an older version), but am now having issues using lombok in existing projects.
The lombok jar is imported into the project:
And the class imports for AllArgsConstructor, Getter and Setter do not throw any errors in the classes they are required for:
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@AllArgsConstructor(access = AccessLevel.PROTECTED)
public class Greeting {
private @Getter @Setter final long id;
private @Getter @Setter final String content;
}
However, these annotations are not being respected anywhere else in the project.
Firstly, both the "id" and "content" fields above show as uninitialised final fields due to there being no apparent constructor:
Similarly attempting to construct in a RestController class elsewhere shows a "constructor undefined" error:
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@GetMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
Greeting greeting = new Greeting(counter.incrementAndGet(), String.format(template, name));
System.out.println(greeting.getContent());
return greeting;
}
}
The getter method "getContent()" in the above code always shows an "undefined" error (similarly if trying to add implicit setters):
If I add explicit constructors, getters and setters back into the Greeting class, everything works as expected: