<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<entity.target.dir>src/main/java/</entity.target.dir>
<dao.resources.dir>src/main/resources/</dao.resources.dir>
</properties>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<dependencies>
<!--數(shù)據(jù)庫驅動 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<phase>package</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<!--允許移動生成的文件 -->
<verbose>true</verbose>
<!-- 是否覆蓋 -->
<overwrite>true</overwrite>
<!-- 自動生成的配置 -->
<configurationFile>
src/main/resources/mybatis-generator.xml
</configurationFile>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="DB2Tables" targetRuntime="MyBatis3" defaultModelType="flat">
<plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin">
<property name="searchString" value="[e|E]xample$"/>
<property name="replaceString" value="Criteria"/>
</plugin>
<!-- optional泵额,旨在創(chuàng)建class時配深,對注釋進行控制 -->
<commentGenerator>
<property name="suppressDate" value="ture"/>
</commentGenerator>
<!--jdbc的數(shù)據(jù)庫連接 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/xxx?useSSL=false" userId="root"
password="root">
</jdbcConnection>
<!-- 非必需,類型處理器嫁盲,在數(shù)據(jù)庫類型和java類型之間的轉換控制-->
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- Model模型生成器,用來生成含有主鍵key的類篓叶,記錄類 以及查詢Example類
targetPackage 指定生成的model生成所在的包名
targetProject 指定在該項目下所在的路徑
-->
<javaModelGenerator targetPackage="com.xubh.durid.model" targetProject="${entity.target.dir}">
<!-- 是否對model添加 構造函數(shù) -->
<!--<property name="constructorBased" value="true"/>-->
<!-- 是否允許子包,即targetPackage.schemaName.tableName -->
<property name="enableSubPackages" value="true"/>
<!-- 建立的Model對象是否 不可改變 即生成的Model對象不會有 setter方法羞秤,只有構造方法 -->
<!-- <property name="immutable" value="true"/>-->
<!-- 是否對類CHAR類型的列的數(shù)據(jù)進行trim操作 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 自動生成xml(但是好像一直沒有生成功缸托,反正也不用xml) -->
<!--Mapper映射文件生成所在的目錄 為每一個數(shù)據(jù)庫的表生成對應的SqlMap文件 -->
<sqlMapGenerator targetPackage="com.xubh.durid.model.mapper" targetProject="${dao.resources.dir}">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 客戶端代碼,生成易于使用的針對Model對象和XML配置文件 的代碼
type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper對象
type="MIXEDMAPPER",生成基于注解的Java Model 和相應的Mapper對象
type="XMLMAPPER",生成SQLMap XML文件和獨立的Mapper接口
-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.xubh.durid.model.mapper"
implementationPackage="com.xubh.durid.model.mapper.impl"
targetProject="${entity.target.dir}">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!--<table tableName="user" domainObjectName="User">-->
<!-- optional , only for mybatis3 runtime
自動生成的鍵值(identity,或者序列值)
如果指定此元素瘾蛋,MBG將會生成<selectKey>元素俐镐,然后將此元素插入到SQL Map的<insert> 元素之中
sqlStatement 的語句將會返回新的值
如果是一個自增主鍵的話,你可以使用預定義的語句,或者添加自定義的SQL語句. 預定義的值如下:
Cloudscape This will translate to: VALUES IDENTITY_VAL_LOCAL()
DB2: VALUES IDENTITY_VAL_LOCAL()
DB2_MF: SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1
Derby: VALUES IDENTITY_VAL_LOCAL()
HSQLDB: CALL IDENTITY()
Informix: select dbinfo('sqlca.sqlerrd1') from systables where tabid=1
MySql: SELECT LAST_INSERT_ID()
SqlServer: SELECT SCOPE_IDENTITY()
SYBASE: SELECT @@IDENTITY
JDBC: This will configure MBG to generate code for MyBatis3 suport of JDBC standard generated keys. This is a database independent method of obtaining the value from identity columns.
identity: 自增主鍵 If true, then the column is flagged as an identity column and the generated <selectKey> element will be placed after the insert (for an identity column). If false, then the generated <selectKey> will be placed before the insert (typically for a sequence).
-->
<!-- <generatedKey column="" sqlStatement="" identity="" type=""/>-->
<!-- optional.
列的命名規(guī)則:
MBG使用 <columnRenamingRule> 元素在計算列名的對應 名稱之前哺哼,先對列名進行重命名京革,
作用:一般需要對BUSI_CLIENT_NO 前的BUSI_進行過濾
支持正在表達式
searchString 表示要被換掉的字符串
replaceString 則是要換成的字符串,默認情況下為空字符串幸斥,可選
-->
<!-- <columnRenamingRule searchString="" replaceString=""/>-->
<!-- optional.告訴 MBG 忽略某一列
column匹摇,需要忽略的列
delimitedColumnName:true ,匹配column的值和數(shù)據(jù)庫列的名稱 大小寫完全匹配,false 忽略大小寫匹配
是否限定表的列名甲葬,即固定表列在Model中的名稱
-->
<!-- <ignoreColumn column="PLAN_ID" delimitedColumnName="true" />-->
<!--optional.覆蓋MBG對Model 的生成規(guī)則
column: 數(shù)據(jù)庫的列名
javaType: 對應的Java數(shù)據(jù)類型的完全限定名
在必要的時候可以覆蓋由JavaTypeResolver計算得到的java數(shù)據(jù)類型. For some databases, this is necessary to handle "odd" database types (e.g. MySql's unsigned bigint type should be mapped to java.lang.Object).
jdbcType:該列的JDBC數(shù)據(jù)類型(INTEGER, DECIMAL, NUMERIC, VARCHAR, etc.)廊勃,該列可以覆蓋由JavaTypeResolver計算得到的Jdbc類型,對某些數(shù)據(jù)庫而言,對于處理特定的JDBC 驅動癖好 很有必要(e.g. DB2's LONGVARCHAR type should be mapped to VARCHAR for iBATIS).
typeHandler:
-->
<!--<columnOverride column="" javaType="" jdbcType="" typeHandler="" delimitedColumnName="" />-->
</context>
</generatorConfiguration>
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者