-
Notifications
You must be signed in to change notification settings - Fork 2
文件配置
Yi Li edited this page Aug 16, 2020
·
9 revisions
配置分为两个部分。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.liyiorg</groupId>
<artifactId>mbg-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mbg-example</name>
<description>Demo project for Spring Boot</description>
<properties>
<mybatis.generator.overwrite>true</mybatis.generator.overwrite>
<mybatis.generator.tableNames></mybatis.generator.tableNames>
</properties>
<dependencies>
<!-- 引入generator 插件依赖 -->
<dependency>
<groupId>com.github.liyiorg</groupId>
<artifactId>mboog-support</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 引入suport 依赖 -->
<plugin>
<!-- maven run: mybatis-generator:generate -->
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.6</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>com.github.liyiorg</groupId>
<artifactId>mboog-generator</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
在 classpath 目录下添加文件 generatorConfig.xml,并配置数据库连接,以及要生成的表对象。
<?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="MbgTables" targetRuntime="MyBatis3">
<property name="autoDelimitKeywords" value="true"/>
<property name="beginningDelimiter" value="`"/> <!-- " -->
<property name="endingDelimiter" value="`"/>
<plugin type="org.mybatis.generator.plugins.CachePlugin">
<property name="cache_readOnly" value="false"/>
<!--<property name="cache_type" value="org.mybatis.caches.memcached.MemcachedCache"/>-->
<!--cache_eviction
cache_flushInterval
cache_readOnly
cache_size
cache_type-->
</plugin>
<plugin type="mboog.generator.plugins.CachePlugin"/>
<!-- ExampleBase plugins -->
<plugin type="mboog.generator.plugins.RulesDelegatePlugin"/>
<plugin type="mboog.generator.plugins.ColumnIsPlugin"/>
<plugin type="mboog.generator.plugins.ExampleBasePlugin"/>
<plugin type="mboog.generator.plugins.ExampleCPlugin"/>
<plugin type="mboog.generator.plugins.CommonWhereClausePlugin"/>
<!-- Pagination plugins MySQLPaginationPlugin,OraclePaginationPlugin,PostgreSQLPaginationPlugin-->
<plugin type="mboog.generator.plugins.pagination.MySQLPaginationPlugin"/>
<!-- Upsert plugins MySQLUpsertPlugin -->
<plugin type="mboog.generator.plugins.upsert.MySQLUpsertPlugin"/>
<plugin type="mboog.generator.plugins.BatchInsertPlugin"/>
<plugin type="mboog.generator.plugins.OptimisticLockPlugin"/>
<!-- Example Criterion plugins-->
<plugin type="mboog.generator.plugins.CriterionPlugin"/>
<!-- Select column plugins -->
<plugin type="mboog.generator.plugins.ColumnListPlugin"/>
<!-- Mapper generator plugins -->
<plugin type="mboog.generator.plugins.MapperGeneratorPlugin"/>
<!-- Service generator plugins -->
<plugin type="mboog.generator.plugins.ServiceGeneratorPlugin"/>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<plugin type="org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin"/>
<commentGenerator>
<property name="addRemarkComments" value="true"/>
<property name="suppressDate" value="true"/>
</commentGenerator>
<!-- 自定义数据库连接信息 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://xxxx:3306/test?characterEncoding=utf8&useInformationSchema=True"
userId="user"
password="password">
</jdbcConnection>
<javaTypeResolver type="mboog.generator.internal.types.JavaTypeResolverImpl">
<property name="forceBigDecimals" value="false" />
<property name="jsr310" value="true" />
<property name="tinyintToInteger" value="true" />
<property name="smallintToInteger" value="true" />
</javaTypeResolver>
<javaModelGenerator targetPackage="com.github.liyiorg.mbgexample.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.github.liyiorg.mbgexample.mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.github.liyiorg.mbgexample.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!--
<table schema="" tableName="tableName" domainObjectName="domainObjectName">
<property name="useActualColumnNames" value="true" />
<property name="remarks" value="1" /> [0,1,2,3]
<property name="lock" value="true" /> [true,false or column_name]
<property name="readonly" value="true" />
<property name="virtualKeyColumns" value="id1,id2" />
<property name="cache" value="true" /> [true,false or XNameMapper]
<property name="graphql" value="true" />[true,false or col1,col2]
<generatedKey column="id" sqlStatement="MySql" identity="true" />
<columnOverride column="" property="" delimitedColumnName="true"/>
</table>
-->
<!-- 自定义添加数据加表 -->
<table schema="" tableName="employee" domainObjectName="Employee">
<property name="lock" value="true" />
</table>
</context>
</generatorConfiguration>