1)添加lombok依赖

<dependency>
           <groupId>org.projectlombok</groupId>
           <artifactId>lombok</artifactId>
         </dependency>

 

2)

@Slf4j//等同于
@Getter
@Setter
public class User {
    
   private String name;
   private Integer age;
    
    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return "username: "+name+"age:"+age;
    }
   //lombok底层使用字节码技术,ASM  帮你在内存中去修改字节码文件,生成getset方法
   //需要生成GetSet方法
    public static void main(String[] args) {
        User user =new User();
        user.setName("谭磊");
        user.setAge(20);
        log.info("AAA");
        System.out.println(user.toString());
        
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-10-02
  • 2021-11-04
  • 2021-07-16
  • 2021-09-29
  • 2022-12-23
  • 2021-05-21
  • 2021-06-15
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-07-13
  • 2021-07-31
  • 2021-06-16
相关资源
相似解决方案