1 Star 0 Fork 4

lou / mybatis-generator-lombok-plugin

加入 Gitee
与超过 600 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

MyBatis Generator Lombok plugin

A plugin for MyBatis Generator to use Lombok annotations instead of getters and setters. Helps to reduce the amount of generated boilerplate code.

Code before applying the Lombok plugin:

package example.dto;

public class Contact {
    private Long id;

    private String firstName;

    private String lastName;

    private String phone;

    private String email;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}

Code after applying the Lombok plugin (much shorter):

package example.dto;

import lombok.Data;

@Data
public class Contact {
    private Long id;

    private String firstName;

    private String lastName;

    private String phone;

    private String email;
}

Using the plugin

First things first, clone this repository locally and run:

mvn clean install

Then, in your MyBatis Generator configuration, include the plugin:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
    <context id="example"
             targetRuntime="MyBatis3Simple"
             defaultModelType="flat">
        <!-- include the plugin -->
        <plugin type="com.softwareloop.mybatis.generator.plugins.LombokPlugin"/>

        <!-- other configurations -->

    </context>
</generatorConfiguration>

If you run MyBatis Generator from Maven, you can add the plugin as a dependency for mybatis-generator-maven-plugin:

<plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>${mybatis.generator.version}</version>
    <configuration>
        <overwrite>true</overwrite>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.softwareloop</groupId>
            <artifactId>mybatis-generator-lombok-plugin</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>

Author

Paolo Predonzani

仓库评论 ( 0 )

你可以在登录后,发表评论

简介

暂无描述 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/xiaonian321/mybatis-generator-lombok-plugin.git
git@gitee.com:xiaonian321/mybatis-generator-lombok-plugin.git
xiaonian321
mybatis-generator-lombok-plugin
mybatis-generator-lombok-plugin
master

搜索帮助