为什么我无法在 Spring 引导应用程序中使用 @Getter 和 @Setter 注释访问 get 和 set 方法? ||龙目岛

why I am not able to access the get and set method using @Getter and @Setter Annotation in Spring Boot Application? || Lombok

为什么我无法在 Spring 引导应用程序中使用 @Getter 和 @Setter 注释访问 get 和 set 方法?

    import lombok.Getter;
    import lombok.Setter;

public class Card {
    
    @Getter//(lazy = true) 
    @Setter
    private int id;
    @Getter
    @Setter
    private String cardvalue;

}

在我的控制器中 class 它说这两个方法都未定义。 注意:在pom.xml中添加了Lombok依赖

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

并验证文件是否在 Maven 依赖项中成功下载。

是否需要进行任何配置才能使用使用注释的方法? 请帮忙!

如果您使用的是 IntelliJ,则需要下载 Lombok 插件。您可以从 Preferences -> Plugins -> Lombok 下载

我遇到了同样的问题,也许你需要添加一个 Lombok 插件,至少可以为我或其他人解决这个问题

能否请您参考以下页面?并按照步骤添加Lombok插件

Solution 1

Solution 2

请参考

请参考Eclipse/STS