generator.xml文件与相关配置插件

一,generator.xml配置信息
1
<?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE generatorConfiguration 3 PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" 4 "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> 5 6 <generatorConfiguration> 7 <!--数据库驱动--> 8 <classPathEntry 9 location="D:\.m2\repository\com\oracle\ojdbc6\11.1.0.6\ojdbc6-11.1.0.6.jar"/> 10 <context id="my" targetRuntime="MyBatis3"> 11 <commentGenerator> 12 <property name="suppressDate" value="false"/> 13 <property name="suppressAllComments" value="true"/> 14 </commentGenerator> 15 <!--数据库链接地址账号密码--> 16 <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" 17 connectionURL="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.14.218.60)(PORT = 1555))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = u1bloancrdt)))" 18 userId="bloancrdtdata" 19 password="paic1234"/> 20 <!--生成Model类存放位置--> 21 <javaModelGenerator targetPackage="com.pingan.credit.model.TdModel" 22 targetProject="D:/git/ics.credit/src/main/java"> 23 <property name="enableSubPackages" value="true"/> 24 <property name="trimStrings" value="true"/> 25 </javaModelGenerator> 26 <!--生成映射文件存放位置--> 27 <sqlMapGenerator targetPackage="mybatis" 28 targetProject="D:/git/ics.credit/src/main/resources"> 29 <property name="enableSubPackages" value="true"/> 30 </sqlMapGenerator> 31 <!--生成Dao类存放位置--> 32 <javaClientGenerator targetPackage="com.pingan.credit.dao" 33 targetProject="D:/git/ics.credit/src/main/java" type="XMLMAPPER"> 34 <property name="enableSubPackages" value="true"/> 35 </javaClientGenerator> 36 37 <table tableName="ICS_TD_TDREPORTROOT" 38 domainObjectName="TdReportRoot" 39 enableCountByExample="false" 40 enableUpdateByExample="false" 41 enableDeleteByExample="false" 42 enableSelectByExample="false" 43 selectByExampleQueryId="false" 44 enableInsert="true" 45 enableUpdateByPrimaryKey="false" 46 enableDeleteByPrimaryKey="false"> 47 </table> 48 49 </context> 50 </generatorConfiguration>
二,实现自动生成的相关配置
pom.xml
 1 <plugin>
 2                 <groupId>org.mybatis.generator</groupId>
 3                 <artifactId>mybatis-generator-maven-plugin</artifactId>
 4                 <version>1.3.2</version>
 5                 <configuration>
 6                     <configurationFile>generator/generator.xml</configurationFile>
 7                     <verbose>true</verbose>
 8                     <overwrite>true</overwrite>
 9                 </configuration>
10                 <executions>
11                     <execution>
12                         <id>Generate MyBatis Artifacts</id>
13                         <goals>
14                             <goal>generate</goal>
15                         </goals>
16                     </execution>
17                 </executions>
18                 <dependencies>
19                     <dependency>
20                         <groupId>org.mybatis.generator</groupId>
21                         <artifactId>mybatis-generator-core</artifactId>
22                         <version>1.3.2</version>
23                     </dependency>
24                 </dependencies>
25             </plugin>
三,如何自动生成
在idea中,找到MavenProject----Plugins----mybatis-generator双击即可自动生成model,mapper.xml,dao.

 

posted on 2018-01-18 09:18  T-M  阅读(3277)  评论(0编辑  收藏  举报