MyBatis逆向工程


新建 maven 工程

  
    
      
      
        org.mybatis.generator
        mybatis-generator-maven-plugin
        1.3.6
        
          
            mysql
            mysql-connector-java
            5.1.45
          
        
        
          
          ${basedir}/src/main/resources/generatorConfig.xml
          true
          true
        
      
    
  

resources 目录下创建 generatorConfig.xml 文件

<?xml version="1.0" encoding="UTF-8"?>




  
    
    
    
    
    
      
      
      
    

    
    

    
      
      
    

    
    
      
    

    
      
      
    

    
    

可选参数,默认都是true,会自动生成增删改查,就弄成默认的即可。如果改为 false,有可能不会自动生成 ResultMap

     enableCountByExample="false"
     enableUpdateByExample="false"
     enableDeleteByExample="false"
     enableSelectByExample="false"
     enableSelectByPrimaryKey="false"
     enableUpdateByPrimaryKey="false"
     enableDeleteByPrimaryKey="false"
     selectByPrimaryKeyQueryId="false"
     selectByExampleQueryId="false"