官网:https://www.projectlombok.org/ 点 features 选 稳定
@Getter
@Setter
@ToString
//创建有参构造函数
@AllArgsConstructor
//创建无参构造函数
@NoArgsConstructor
//为final的成员创建构造函数
@RequiredArgsConstructor
//改善 new对象实例化,用建造者模式
@Builder
例子:ShareDTO.builder().id(1).userId(12);
@EqualsAndHashCode
//日志
@Slf4j
//关闭流
@Cleanup
public class CleanupExample {
public static void main(String[] args) throws IOException {
@Cleanup InputStream in = new FileInputStream(args[0]);
@Cleanup OutputStream out = new FileOutputStream(args[1]);
byte[] b = new byte[10000];
while (true) {
int r = in.read(b);
if (r == -1) break;
out.write(b, 0, r);
}
}
}