简体   繁体   English

Spring 启动 lombok @AllArgsConstructor 问题

[英]Spring boot lombok @AllArgsConstructor issue

This is my entity package and I have an error indicating the fields are not used and I can't call getter and setters.这是我的实体 package ,我有一个错误,表明字段未使用,我无法调用 getter 和 setter。

It's like Lombok is not working.就像龙目岛不工作一样。 What exactly is the solution?究竟是什么解决方案?

package com.app.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "userregister")
public class User {

    private String name;
    
    @Id
    private String username;

    private String email;

    private String phone;

    private String password;
    
    private String cpassword;

    private String gender;

}

这是我在图片中的控制器类

The code seems fine.May be your ide is not recognizing lombok dependency.

Please try to add the following dependency into your pom.xml file
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

and Download lombok.jar from the given link
https://projectlombok.org/download

Now if it is zipped unzip it first and then copy it to the directory 
where you have your SpringToolSuits(STS installed).

Let say your STS version is 4.11.0.RELEASE then copy lombok.jar to STS 
directory/sts-4.11.0.RELEASE   i.e. inside STS/sts-4.11.0.RELEASE/

Now try to rebuild and update your project.

https://stackoverflow.com/questions/70934552/sonar-doesnt-pick-lombok-annotations-remove-unused-private-field

Thanks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM