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;
}
}