mybatis 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>
    <!-- 引入 properties 配置文件 -->
    <properties resource="properties/config.properties"/>
    <!-- 數據庫鏈接驅動包 -->
    <classPathEntry location="${mbg.jar}" />
    <context id="MySqlTables" targetRuntime="MyBatis3">
        <!-- 生成的Java文件的編碼 -->
        <property name="javaFileEncoding" value="UTF-8" />
        <!-- 格式化java代碼 -->
        <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter" />
        <!-- 格式化XML代碼 -->
        <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter" />
        <!-- 為生成的Java模型類添加序列化接口 -->
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
        <!-- 為生成的Java模型創建一個toString方法 -->
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin" />
        <!-- 取消注釋 -->
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <property name="suppressAllComments" value="true" />
        </commentGenerator>
        <jdbcConnection driverClass="${default.db.driverClassName}" connectionURL="${default.db.url}" userId="${default.db.username}" password="${default.db.password}" />
        <!-- java類型處理器 用於處理DB中的類型到Java中的類型,默認使用JavaTypeResolverDefaultImpl; 注意一點,默認會先嘗試使用Integer,Long,Short等來對應DECIMAL和 NUMERIC數據類型; -->
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>
        <javaModelGenerator targetPackage="com.shiro.entity" targetProject="${mbg.path}/java">
            <property name="enableSubPackages" value="false" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>
        <sqlMapGenerator targetPackage="mybatis.common.user" targetProject="${mbg.path}/resources">
            <property name="enableSubPackages" value="false" />
        </sqlMapGenerator>
        <javaClientGenerator targetPackage="com.shiro.dao" targetProject="${mbg.path}/java" type="XMLMAPPER">
            <property name="enableSubPackages" value="false" />
        </javaClientGenerator>
        <!-- 生成表並且不生成example -->
        <table schema="" tableName="sys_permission"  enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
               enableUpdateByExample="false" />
        <table schema="" tableName="sys_role"  enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
               enableUpdateByExample="false" />
        <table schema="" tableName="sys_role_permission" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
               enableUpdateByExample="false" />
        <table schema="" tableName="sys_user" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
               enableUpdateByExample="false" />
        <table schema="" tableName="sys_user_role" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
               enableUpdateByExample="false" />
    </context>
</generatorConfiguration>

properties 文件如下:

logback.name=ssm_shiro
logback.path=C:/Users/Public/Desktop
#logback.path=/Users/apple/Desktop/logs

mbg.jar=D:/repo/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar
mbg.path=E:/l/ssm_shiro/src/main
#mbg.jar=/Users/apple/Documents/repository/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar
#mbg.path=/Users/apple/Documents/workspace/eclipse/ssm_shiro/src/main

default.db.username=root
default.db.password=root
default.db.driverClassName=com.mysql.jdbc.Driver
default.db.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/zd?useUnicode=true&characterEncoding=utf8&useSSL=false

db.initialSize=1
db.minIdle=1
db.maxActive=20
db.maxWait=60000
db.timeBetweenEvictionRunsMillis=60000
db.minEvictableIdleTimeMillis=30000

db.validationQuery=SELECT 'x'
db.testWhileIdle=true
db.testOnBorrow=false
db.testOnReturn=false

db.poolPreparedStatements=true
db.maxPoolPreparedStatementPerConnectionSize=20
db.filters=stat,wall,slf4j

 

关注微信公众号

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com