Home  >  Article  >  Java  >  Introduction to mybatis reverse engineering (code example)

Introduction to mybatis reverse engineering (code example)

不言
不言forward
2019-03-07 16:24:042220browse

This article brings you an introduction to mybatis reverse engineering (code examples). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

First create a test class:

Write the following code in the main method:

List  warnings = new ArrayList ();
boolean overwrite = true;
File configFile = new File("generator.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,callback,warnings);
myBatisGenerator.generate(null);

Create a new generator.xml file in the project directory:






   
   
   
        
   
  
  
    
    
    

    
      
    

    
    
      
      
    

    
    
      
    

    
    
      
    

    
    

The last table tag is the name of the table in your own database; the connection information of the database needs to be modified by yourself

Executing the test class will automatically generate the data in the table tag set above The corresponding entity classes, dao layer interfaces and corresponding mapper mappings in the table

In addition, please download the required jar package yourself: https:// github.com/Pei-Qi/mybatis_jar

The above is the detailed content of Introduction to mybatis reverse engineering (code example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete