mybatis generatorConfig.xml 自动生成
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于mybatis generatorConfig.xml 自动生成的主要内容,如果未能解决你的问题,请参考以下文章