springboot mybatis-generator自动生成bean和dao

1、在pom.xml里添加maven插件

[java]   view plain  copy
  1.   
  2.                 org.mybatis.generator  
  3.                 mybatis-generator-maven-plugin  
  4.                 1.3.5  
  5.                   
  6.                       
  7.                          mysql  
  8.                          mysql-connector-java  
  9.                          5.1.39  
  10.                       
  11.                       
  12.                         org.mybatis.generator  
  13.                         mybatis-generator-core  
  14.                         1.3.5  
  15.                       
  16.                   
  17.                   
  18.                       
  19.                         Generate MyBatis Artifacts  
  20.                         package  
  21.                           
  22.                             generate  
  23.                           
  24.                       
  25.                   
  26.                   
  27.                       
  28.                     true  
  29.                       
  30.                     true  
  31.                       
  32.                       
  33.                         src/main/resources/mybatis-generator.xml  
  34.                   
  35.               

2、在resources下创建mybatis-generator.xml


[java]   view plain  copy
  1. "1.0" encoding="UTF-8"?>  
  2.         PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"  
  3.         "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">  
  4.   
  5.       
  6.     "DB2Tables"    targetRuntime="MyBatis3">  
  7.           
  8.             "suppressDate" value="true"/>  
  9.             "suppressAllComments" value="true"/>  
  10.           
  11.           
  12.         "com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.155:3308/nonobank_app" userId="stb_nono_app" password="csstbnonobank@2016">  
  13.           
  14.           
  15.             "forceBigDecimals" value="false"/>  
  16.           
  17.           
  18.         "com.demo.model" targetProject="src/main/java">  
  19.             "enableSubPackages" value="true"/>  
  20.             "trimStrings" value="true"/>  
  21.           
  22.           
  23.         "com.demo.mapper" targetProject="src/main/java">  
  24.             "enableSubPackages" value="true"/>  
  25.           
  26.           
  27.           
  28.         "ANNOTATEDMAPPER" targetPackage="com.demo.dao" targetProject="src/main/java">  
  29.             "enableSubPackages" value="true"/>  
  30.           
  31.           
  32.         "user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">  
  33.       
  34.   

3、在src/main/java/com/demo/下创建dao、model、mapper文件夹。


4、在maven project下双击mybatis-generator插件下的mybatis-generator:generate


你可能感兴趣的:(springboot)