Giter Site home page Giter Site logo

mybatis-extension-plugin's Introduction

mybatis-extension-plugin

English | δΈ­ζ–‡


Add dependency (example)
<dependencies>
  <dependency>
    <groupId>io.github.mioxs</groupId>
    <artifactId>mybatis-extension-plugin</artifactId>
    <version>1.4.2</version>
    <scope>runtime</scope>
    <optional>true</optional>
  </dependency>
</dependencies>

<build>
<plugins>
  <plugin>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.4.1</version>
    <executions>
      <execution>
        <id>Generate MyBatis Artifacts</id>
        <phase>deploy</phase>
        <goals>
          <goal>generate</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <verbose>true</verbose>
      <overwrite>true</overwrite>
    </configuration>
    <dependencies>
      <!--mysql As an example-->
      <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.31</version>
      </dependency>
      <!--mybatis-extension-plugin-->
      <dependency>
        <groupId>io.github.mioxs</groupId>
        <artifactId>mybatis-extension-plugin</artifactId>
        <version>1.4.2</version>
      </dependency>
    </dependencies>
  </plugin>
</plugins>
</build>

Plugin usage

LombokPlugin (lombok generation)

property defaults introduction
data false include getter,setter,toString,equalsAndHashCode,requiredArgsConstructor
getter false getter
setter false getter
toString false toString
equalsAndHashCode false equalsAndHashCode
builder false builder
noArgsConstructor false noArgsConstructor
allArgsConstructor false allArgsConstructor
requiredArgsConstructor false requiredArgsConstructor
Examples
  • The <plugin> element is a child element of the <context> element. Any number of plugins can be specified in the context.
<plugin type="io.github.mioxs.mybatis.LombokPlugin">
    <property name="data" value="true"/>
    <property name="builder" value="true"/>
    <property name="noArgsConstructor" value="true"/>
    <property name="allArgsConstructor" value="true"/>
</plugin>

DomainPlugin (Entity class extension)

property defaults introduction
serializable false Whether to implement Serializable
dateSerialize false Date serialization only supports JDK 8 date types
json null Date deserialization only supports JDK8 date types (options: fastJson, jackson)
Examples
  • The <plugin> element is a child element of the <context> element. Any number of plugins can be specified in the context.
<plugin type="io.github.mioxs.mybatis.DomainPlugin">
    <property name="serializable" value="true"/>
    <property name="dateSerialize" value="true"/>
    <property name="json" value="jackson"/>
</plugin>

RepositoryPlugin (Data Access Object DAO Extension)

property defaults introduction
suppressAllComments false Whether to remove the generated comments
repository null Dao parent class, default is null
Examples
  • The <plugin> element is a child element of the <context> element. Any number of plugins can be specified in the context.
<plugin type="io.github.mioxs.mybatis.RepositoryPlugin">
    <property name="suppressAllComments" value="true"/>
    <property name="repository" value="org.example.MybatisRepository"/>
</plugin>

ServicePlugin (Service generation)

property defaults introduction
targetProject null Generate path example: src/main/java
targetPackage null generate package path example: org.example.service
basicService null service interface parent class default is null
basicServiceImpl null serviceImpl parent class, default is null
Examples

*The <plugin> element is a child element of the <context> element. Any number of plugins can be specified in the context.

<plugin type="io.github.mioxs.mybatis.ServicePlugin">
   <property name="targetProject" value="src/main/java"/>
   <property name="targetPackage" value="org.example.service"/>
   <property name="basicService" value="org.example.BaseService"/>
   <property name="basicServiceImpl" value="org.example.BaseServiceImpl"/>
</plugin>

ControllerPlugin (Controller generation)

property defaults introduction
targetProject null Generate path example: src/main/java
targetPackage null Generate package path example: org.example.controller
rest false true for @RestController, false for @Controller
respond null The controller returns the result set. The default is null
Examples
  • The <plugin> element is a child element of the <context> element. Any number of plugins can be specified in the context.
<plugin type="io.github.mioxs.mybatis.ControllerPlugin">
   <property name="targetProject" value="src/main/java"/>
   <property name="targetPackage" value="org.example.controller"/>
   <property name="rest" value="true"/>
   <property name="respond" value="org.example.Respond"/>
</plugin>
Generate impressions (partial code)
@Slf4j
@RestController
@RequestMapping("example")
public class ExampleController {

    @Autowired
    private ExampleService exampleService;
    
    @GetMapping("findAll")
    public Respond findAll() {
       return null;
    }
    //...
}

Generate

  • Idea opens the right side maven->plugins->mybatis-generator-> mybatis-generator:generator Click to execute
  • Or mvn mybatis-generator:generator

mybatis-extension-plugin's People

Contributors

mioxs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.