-
Notifications
You must be signed in to change notification settings - Fork 10
Lombok
mythos edited this page Jul 21, 2018
·
7 revisions
目录 start
目录 end |2018-07-08| 码云 | CSDN | OSChina
简化JavaBean 更为直观 省去了Setter Getter toString hashCode 构造器等方法
一定有人就会跳出来说 在IDE中几个快捷键的事情,何必这么复杂,那他们一定是没有遇到修改的时候吧, 改个属性的名字,类型, 对应的方法你需要改吧, 但是使用lombok就不用担心了
暂时还没有想到
Lombok在IDE中安装插件是为了编译和构建中能够动态的添加Getter Setter 等方法, 而在Maven或者Gradle中添加是为了注解能够引用得到??
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.8.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>而static有还是有可能被new出多个实例的
配置编译插件
<!--lombok-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
<encoding>UTF-8</encoding>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
<fork>true</fork>
<compilerArguments>
<javaAgentClass>lombok.launch.Agent</javaAgentClass>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.3-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.5.0-01</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>
</dependencies>
</plugin>添加依赖
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>- Lombok 注解在线帮助文档:http://projectlombok.org/features/index.
-
@Data:注解在类上;提供类所有属性的 getter 和 setter 方法,此外还提供了equals、canEqual、hashCode、toString 方法 -
@Setter:注解在属性上;为属性提供 setter 方法 -
@Getter:注解在属性上;为属性提供 getter 方法 -
@NoArgsConstructor:注解在类上;为类提供一个无参的构造方法 -
@AllArgsConstructor:注解在类上;为类提供一个全参的构造方法
- @Log4j
- @Log4j2
- @Slf4j
用上logback, 但是这个不是一个接口规范么TODO
- Introduction
- ApiAndDoc
- Platform
- Process
- Repository
- SUMMARY
- Website
- 【 Article 】
- 【 Blog 】
- 【 Database 】
- 【 FrontEnd 】
- 【 FrontEnd/Frame 】
- 【 FrontEnd/Node 】
- Hexo
- JavaScript
- LearnPS
- ResponseCode
- ViewSolution
- 【 Functional 】
- 【 Go 】
- 【 Java 】
- 【 Java/AdvancedLearning 】
- 【 Java/Framework 】
- 【 Java/MSA 】
- 【 Java/Spring 】
- 【 Java/TemplateEngine 】
- 【 Java/Tool 】
- AlibabaJavaStandard
- EE
- JavaSE
- Log
- MIS
- RESTful
- ZenOfPattern
- 【 Linux 】
- 【 Linux/Alpine 】
- 【 Linux/Arch 】
- 【 Linux/Base 】
- 【 Linux/Centos 】
- 【 Linux/Container 】
- 【 Linux/Debian 】
- 【 Linux/Tool 】
- 【 Linux/Vcs 】
- JavaDevInit
- 【 MyBlog 】
- 【 MyBlog/Problem 】
- 2018-3-15-install-deepin
- why-put-netty-in-tomcat
- 【 Python 】
- 【 Reactive 】
- 【 Script 】
- 【 Skills 】
- 【 Skills/CS 】
- 【 Skills/Document 】
- 【 Skills/Ecology 】
- 【 Skills/FrameWork 】
- 【 Skills/Soft 】
- 【 Skills/Spider 】
- 【 Skills/Test 】
- 【 Skills/Work 】
- AppManual
- CelebrityQuotes
- CodingThinking
- Problem
- RegularExpression
- SoftwareDesignEngineer
- 【 Windows 】