Home  >  Article  >  Database  >  MyBatis reverse engineering analysis and simple tutorial (with code)

MyBatis reverse engineering analysis and simple tutorial (with code)

php是最好的语言
php是最好的语言Original
2018-08-02 14:11:451772browse

MyBatis's reverse engineering

1: What is reverse engineering.

MyBatis是一款优秀的持久层框架,它支持定制化SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录。

当数据库表比较多的时候,重复的创建pojo对象和简单的数据库表的(CRUD)操作的mapper,效率低,官方给出了使用mybatis Generator用来根据数据库表逆向生成pojo和mapper文件,极大的方便开发。

2: Simple tutorial

  • Add plug-in to maven’s pom.xml

 jar


        
        
            org.mybatis
            mybatis
        
        
            org.mybatis
            mybatis-spring
        
        
            com.github.miemiedev
            mybatis-paginator
        
        
            com.github.pagehelper
            pagehelper
        
        
        
            mysql
            mysql-connector-java
        
        
        
            com.alibaba
            druid
        

        
            org.mybatis.generator
            mybatis-generator-core
            1.3.6
        
    
    
        
            
            
                org.mybatis.generator
                mybatis-generator-maven-plugin
                1.3.7
                
                    
                    src/main/resources/generatorConfig.xml
                    true
                    true
                
            
        
    
  • Create the configuration file generatorConfig.xml




    
    
    
    

    
        
            
            
            
        
        
        
        
        
        
        
            
        
        
        
        
        
            
            
            
            
        
        
        
            
            
        
        
        
            
            
        
        
        
        
        
        
        
  • Run the Generator class to generate

I have already completed the project and downloaded it You can run

Related articles:

Getting started with MyBatis (7)---Reverse Engineering

Spring SpringMVC MyBatis in-depth learning and construction ——MyBatis reverse engineering

Related videos:

MySQLi process-oriented quick introduction

The above is the detailed content of MyBatis reverse engineering analysis and simple tutorial (with code). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn