yangyang12138

导航

lombok

lombak能很好减少冗余代码

 

首先安装 lombok插件,安装首先要下载https://projectlombok.org/download

然后运行 java -jar lombak.jar 选择eclipse安装路径 点击安装

 

在eclipse.ini中 添加 

  -javaagent:lombok.jar 
 -Xbootclasspath/a:lombok.jar
新建项目
添加maven引用
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>lombok</groupId>
  <artifactId>demo-lom</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.8</version>
        </dependency>
        
  </dependencies>
  
  <build>
        <plugins>
            <plugin>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-maven-plugin</artifactId>
                <version>1.16.6.1</version>
            </plugin>
        </plugins>
    </build>
</project>
package demo;

import lombok.Data;
import lombok.extern.log4j.Log4j;

public class Test {
    
    @Data
    public static class Student{
        private String name;
        private Integer age;
    }
    
    public static void main(String[] args) {
        Student student = new Student();
        
        student.setName("利尔哈");
        System.out.println(student.getName());
    }

}

 

 

posted on 2017-12-23 00:24  杨杨09265  阅读(179)  评论(0编辑  收藏  举报