IDEA使用mybatis-generator

环境版本

-mysql 5.7.20
-springboot 2.1.10.RELEASE
-jdk 1.8
1.新建项目
IDEA使用mybatis-generator_第1张图片
QQ截图20191115235129.png
2.在pom文件的下的添加以下配置
IDEA使用mybatis-generator_第2张图片
QQ截图20191115235307.png

        
            
                org.springframework.boot
                spring-boot-maven-plugin
            

            
                org.mybatis.generator
                mybatis-generator-maven-plugin
                1.3.5
                
                    
                    true
                    
                    true
                    src/main/resources/generatorConfig.xml
                
                
                
                    
                        mysql
                        mysql-connector-java
                        5.1.17
                    
                
            
        
    
3.在项目中新建包
IDEA使用mybatis-generator_第3张图片
QQ截图20191115235621.png
4.在mysql中建立测试数据库wg_inset
IDEA使用mybatis-generator_第4张图片
QQ截图20191115235743.png
5.在resources下创建generatorConfig.xml
IDEA使用mybatis-generator_第5张图片
QQ截图20191116000058.png

IDEA使用mybatis-generator_第6张图片
QQ截图20191116000406.png
6.配置文件躯体内容如下



    
    
    
    
        
        
            
            
            
        
        
        
        
        
            
            
            
            
        
        
        
        
            
            
            
            
            
            
            
            
        
        
        
            
            
        
        
        
            
            
        
        
        
7.跑起来看是否成功
IDEA使用mybatis-generator_第7张图片
QQ截图20191116000745.png
8.在IDEA控制台看输出信息
"D:\Program Files\Java\jdk1.8.0_172\bin\java.exe" -Dmaven.multiModuleProjectDirectory=D:\work\kaiyuan\work\mybatisgenerator "-Dmaven.home=D:\Program Files\tool\apache-maven-3.5.2" "-Dclassworlds.conf=D:\Program Files\tool\apache-maven-3.5.2\bin\m2.conf" -javaagent:C:\Users\Administrator\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\191.6183.87\lib\idea_rt.jar=54437:C:\Users\Administrator\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\191.6183.87\bin -Dfile.encoding=UTF-8 -classpath "D:\Program Files\tool\apache-maven-3.5.2\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version2019.1 -s "D:\Program Files\tool\apache-maven-3.5.2\setting.xml" org.mybatis.generator:mybatis-generator-maven-plugin:1.3.5:generate
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building mybatisgenerator 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- mybatis-generator-maven-plugin:1.3.5:generate (default-cli) @ mybatisgenerator ---
[INFO] Connecting to the Database
[INFO] Introspecting table student
[INFO] Introspecting table post
[INFO] Generating Record class for table student
[INFO] Generating Mapper Interface for table student
[INFO] Generating SQL Map for table student
[INFO] Saving file StudentMapper.xml
[INFO] Saving file Student.java
[INFO] Saving file StudentMapper.java
[WARNING] Table configuration with catalog null, schema null, and table post did not resolve to any tables
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.410 s
[INFO] Finished at: 2019-11-15T23:39:17+08:00
[INFO] Final Memory: 14M/155M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0
9.查看生成的文件
IDEA使用mybatis-generator_第8张图片
QQ截图20191116001049.png

到此springboot快速生成mybatis所需要的实体,dao接口,以及xml文件完成了!

你可能感兴趣的:(IDEA使用mybatis-generator)