Lombok 不创建构造函数

Lombok doesnt create constructors

@AdilOoze 的解决方案

If you are using IntelliJ please turn on annotation processing in the settings

问题

昨天一切正常。今天我添加了 gson 依赖,但它不再起作用了:(

当我手动创建构造函数时一切正常

public static void main(String[] args) {
    List<Person> list = new ArrayList<Person>();
    list.add(new Person("AA","xx", 18));
    list.add(new Person("BB", "yy", 21));
    list.add(new Person("CC", "zz", 36));

    Gson gson = new Gson();
    String json = gson.toJson(list);

    System.out.println(json);
}

Person.class 与 @AllArgsConstructor@RequiredArgsConstructor

public class Person {
    @NonNull private String name;
    private String lastname;
    @NonNull private int age;
}

除非我在pom.xml中做错了什么

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

    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.6</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>11</source>
                <target>11</target>
            </configuration>
        </plugin>
    </plugins>
</build>

如果您使用的是 IntelliJ,请在设置中打开注释处理

注意:您可能还需要安装 IntelliJ Lombok 插件