I have the code below in a Maven project which compiles and runs from the command line (OpenJDK 15.0.2 running in Ubuntu under Windows Subsystem for Linux). It uses Lombok 1.18.20 and version 2.12.3 of the relevant Jackson libraries.
Eclipse 20210312-0638 is running under the Windows OpenJDK 15.0.2 (I had the same behaviour with the Eclipse built-in JRE, installed the windows JDK to see if it helped). Lombok 1.18.20 is installed in Eclipse (and shows up in the About... dialog).
When I run the class below as a Java application in Eclipse, I get:
Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `lomboktest.Main$Input` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
I've decompiled the class files created by the command-line Maven build and by running the Maven update in Eclipse. The Eclipse version is missing the @ConstructorProperties annotation, but it's there in the command-line version. The constructor, getters and setters are being created by the @Value annotation as expected in the Eclipse version, so Lombok is doing the job to some extent.
I have lombok.config in the root directory of the project:
lombok.anyConstructor.addConstructorProperties = true
config.stopBubbling = true
If I add an explicit all-args contructor with the @ConfigurationProperties annotation, then everything runs fine in Eclipse.
I'm at a loss as to where to look to find the difference. I've tinkered with any annotation-related settings I can find in Eclipse, without success. I've seen some posts about module dependencies affecting the Lombok annotations, but I'm not (knowingly) using modules.
Can anybody suggest what I need to do to get this working in Eclipse, or at least something I can investigate next to work out what the problem is?
package lomboktest;
import java.io.InputStream;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import lombok.Value;
public class Main {
@Value
public static class Input
{
private String a;
private String b;
}
public static void main(String[] args) throws Exception
{
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
try (InputStream input = Main.class.getResourceAsStream("/input.yml"))
{
System.out.println(mapper.readValue(input, Input.class));
}
}
}