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
时间: 2024-08-01 19:11:04

mybatis generatorConfig.xml 自动生成的相关文章

通过mybatis工具generatorConfig.xml自动生成实体,DAO,映射文件

简介 Mybatis属于半自动ORM,可以利用mybatis工具generatorConfig.xml自动生成DAO.实体.映射文件的方式来代替手动书写的方式,这样既提高了工作效率也可以在项目避免出现的一些细微难调试的BUG. 前提条件: 1.需要准备的第三方jar包为: mybatis-generator-core-1.3.2.jar和mysql-connector-java-5.1.39-bin.jar, 其中mybatis-generator-core-1.3.2.jar的下载地址为: h

mybatis使用generator自动生成代码时的类型转换

使用mybatis的generator自动生成代码,但是oracle数据库中number(6,2)总是自动转成BigDecimal,我想要转成的是float类型 这样就写了一个类型转换器,需要继承JavaTypeResolver接口 然后在mybaties配置文件generatorConfig.xml中类型转换配置位置添加上即可 <javaTypeResolver type="com.generator.MyJavaTypeResolver"> <property n

【VS技巧】根据XML自动生成类型

.NET 4.5对应的VS版本(不要问我哪个版本)中新增了一个功能,严重实用,可以根据XML文档生成新类型.这个功能在VS的[编辑]>[选择性粘贴]菜单中.怎么玩?不急,咱们实际操作一下. 以网易新闻中心的RSS源为例,URI必须指向XML文档,我选用了“文化资讯”频道的内容来测试,URI如下: http://book.163.com/special/0092451H/rss_whzx.xml 在浏览器地址栏中输入以上URI,然后打开该RSS源,然后查看源.按全选选中整个XML文档. 然后回到V

利用Vistual Studio自带的xsd.exe工具,根据XML自动生成XSD

利用Vistual Studio自带的xsd.exe工具,根据XML自动生成XSD 1, 命令提示符-->找到vs自带的xsd.exe工具所在的文件夹 例如: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin 注意:win7操作系统“命令提示符”要以管理员身份运行 2,将Xml文件拷贝到xsd.exe工具所在的文件夹,生成的xsd文件也将在这个文件夹中 3,在命令提示符中输入 xsd.exe test.xml, 多个xml文件以空格隔

根据XML自动生成XSD

利用Vistual Studio自带的xsd.exe工具,根据XML自动生成XSD 1, 命令提示符-->找到vs自带的xsd.exe工具所在的文件夹 例如: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin 注意:win7操作系统"命令提示符"要以管理员身份运行 2,将Xml文件拷贝到xsd.exe工具所在的文件夹,生成的xsd文件也将在这个文件夹中 3,在命令提示符中输入 xsd.exe test.xml, 多个x

mybatis利用maven自动生成mapper、xml、domain

第一种方式: 配置maven插件 在src/main/resources下新建generatorConfig.xml   内容如下: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "ht

使用generatorConfig工具自动生成mybatis的实体类以及dao接口和映射文件

1:数据准备 创建一个数据库表 1 CREATE TABLE `logininfo` ( 2 `id` BIGINT(20) NOT NULL AUTO_INCREMENT, 3 `username` VARCHAR(50) DEFAULT NULL, 4 `password` VARCHAR(200) DEFAULT NULL, 5 `state` TINYINT(4) DEFAULT NULL, 6 PRIMARY KEY (`id`) 7 ) ENGINE=INNODB DEFAULT C

记录下 mybatis.generator 插件自动生成mapper+entity+mapper.xml 少走点坑

Demo  springBoot+Mybatis+oracle 1.创建项目  ...... 2. 配置 generator 文件 在resource 下创建 generatorConfig.xml 文件 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator C

Mybatis Generator代码自动生成(实体类、dao层、映射文件)

写了一段时间增删改查有点厌烦,自己找了下网上的例子鼓捣了下自动生成. 首先得有一个配置文件: generatorConfig.xml <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"