MyBatis三剑客

MyBatis三剑客就是

 MyBatis Generator,MyBatis Pager,Mybatis Plugin

1.通过generator产生与数据库对应的mapper文件和java pojo,里面包含了各种常用的sql操作
在pom.xml中:

<plugins>
      <plugin>
        <groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.2</version>
        <configuration>
          <verbose>true</verbose>
          <overwrite>true</overwrite>
        </configuration>
        <executions>
          <execution>
            <id>Generate MyBatis Artifacts</id>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.mybatis.generator</groupId>
            <artifactId>mybatis-generator-core</artifactId>
            <version>1.3.2</version>
          </dependency>
        </dependencies>
      </plugin>
2.通过pager进行页面分页
原理是spring对sql操作进行切面配置,计算count,做相应的分页操作
在pom.xml中

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>x.x.x</version>
</dependency>
<dependency>
    <groupId>com.github.miemiedev</groupId>
    <artifactId>mybatis-paginator</artifactId>
    <version>1.2.17</version>
</dependency>

<dependency>
    <groupId>com.github.jsqlparser</groupId>
    <artifactId>jsqlparser</artifactId>
    <version>0.9.4</version>
</dependency>



3.通过mybatis plugin提高开发效率



  • 编辑XML文件时自动补全
  • 提供Mapper接口与配置文件中对应SQL的导航
  • 编辑XML文件时自动补全
  • 根据Mapper接口, 使用快捷键生成xml文件及SQL标签
  • ResultMap中的property支持自动补全,支持级联(属性A.属性B.属性C)
  • 快捷键生成@Param注解
  • XML中编辑SQL时, 括号自动补全
  • XML中编辑SQL时, 支持参数自动补全(基于@Param注解识别参数)
  • 自动检查Mapper XML文件中ID冲突
  • 自动检查Mapper XML文件中错误的属性值
  • 支持Find Usage
  • 支持重构从命名
  • 支持别名
  • 自动生成ResultMap属性
  • 快捷键: Option + Enter(Mac) | Alt + Enter(Windows)

打开IDEA , preference -》 plugins 直接搜索‘mybatis plugin’安装即可,如果没有,或者想要破解版,点下面链接:

http://download.csdn.net/download/aaa1074/10134567


原文地址:https://www.cnblogs.com/loveBolin/p/9614277.html