SpringBoot-lombok插件介绍

lombok插件介绍

lombok插件介绍

常规开发中POJO类必须手写get/set/toString/构造/…等方法,这类操作写起来鸡肋.但是又不得不写. 开发效率低.
所以可以引入lombok插件 自动生成上述的方法.

插件安装

 <!--添加lombok的包-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

在这里插入图片描述

安装插件

在这里插入图片描述

测试

package comjt.pojo;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
@Data
@Accessors(chain = true)//重写了set方法,可以实现链式加载
public class User implements Serializable {
    private Integer id;
    private String name;
//    public User setId(Integer id){
//        this.id = id;
//        return this;
//    }
//    public User setName(String name){
//        this.name = name;
//        return this;
//    }
}

package comjt.controller;

import comjt.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PropertySource(value = "classpath:/msg.properties",encoding = "utf-8")
public class HelloController {
    @Value("${msg}")
    private String msg;
    @GetMapping("/hello")
        public String hello(){
        User user = new User();
        user.setId(100).setName("wxin");
        return "您好SpringBoot"+msg;
        }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值