栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

mybatis辅助神器--自动生成model,dao,mapper

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mybatis辅助神器--自动生成model,dao,mapper

前言

今天分享一个用于mybatis生成代码的神器,经过简单的配置我们可以自动生成数据库里相应的表的model,dao,mapper文件,先上图看下效果

效果
  1. 假如我们数据库有这样一张class

  2. 通过简单配置我们就可以自动生成相应的代码文件:

    • 实体类:

      public class Cla {
          private Integer cid;
      
          private String cname;
      
          private String clocation;
      
          public Integer getCid() {
              return cid;
          }
      
          public void setCid(Integer cid) {
              this.cid = cid;
          }
      
          public String getCname() {
              return cname;
          }
      
          public void setCname(String cname) {
              this.cname = cname == null ? null : cname.trim();
          }
      
          public String getClocation() {
              return clocation;
          }
      
          public void setClocation(String clocation) {
              this.clocation = clocation == null ? null : clocation.trim();
          }
      }
      
    • 接口:

      public interface ClaMapper {
          int deleteByPrimaryKey(Integer cid);
      
          int insert(Cla record);
      
          int insertSelective(Cla record);
      
          Cla selectByPrimaryKey(Integer cid);
      
          int updateByPrimaryKeySelective(Cla record);
      
          int updateByPrimaryKey(Cla record);
      }
      
    • mapper.xml:

      
      
      
        
          
          
          
        
        
          cId, cName, cLocation