Coder Social home page Coder Social logo

mybatis-generator-pagination's Introduction

mybatis generator分页插件 (mybatis generator pagination plugin)

使用方法(how to use)

按照原来使用mybatis generator的方法,只是多加了依赖
as same as the way you use mybatis generator, besides, add one more dependency in your pom.

一切需要手写mapper、DTO等复杂方式来实现分页的都是耍流氓;
everything need to write mappers and DTOs by yourself is bullshit!

一切需要复杂配置的插件都是耍流氓;
all complex configurations are bullshit.

此插件目标是使用最简单的方式实现物理分页,不需要手写代码!!!
aim to provide the simplest way to carry out physical pagination!!!

1.在依赖中加入(in your dependency):

<dependency>
    <groupId>com.rosegun</groupId>
    <artifactId>mybatis-generator-pagination</artifactId>
    <version>1.0.1</version>
</dependency>

2.在插件中加入(in your plugin dependency):

<plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.3.5</version>
    <configuration>
        <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
        <verbose>true</verbose>
        <overwrite>true</overwrite>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.42</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.5</version>
        </dependency>
        <!-- only add this dependency -->
        <dependency>
            <groupId>com.rosegun</groupId>
            <artifactId>mybatis-generator-pagination</artifactId>
            <version>1.0.1</version>
        </dependency>
    </dependencies>
</plugin>

3.在generatorConfig.xml配置文件中加入分页插件(in your generatorConfig.xml):

<plugin type="com.rosegun.plugin.MysqlLimitPlugin"/>

4.生成(generate)

mvn mybatis-generator:generate

唯一一个参数(one more parameter)

为了方便配合spring使用,插件生成的mapper会默认加入 @Repository注解,这样可以避免在IDE中看到警告, 如果你不是处女座或者不需要这个注解,那么在generatorConfig.xml文件中加入如下参数:
to integrate with Springframework and avoid warnings in IDE, this plugin will add @Repositoryto mappers as default, if you're not Virgo or you don't need this annotation, add a property in your generatorConfig.xml

<plugin type="com.rosegun.plugin.MysqlLimitPlugin">
    <property name="addRepositoryAnnotation" value="false"/>
</plugin>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.