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



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值