mybatis自动生成工具
来源:互联网 发布:微信淘宝推广怎么做的 编辑:程序博客网 时间:2024/05/18 03:20
本文参考:http://www.mybatis.org/generator/index.html
利用mybatis自动生成工具来生成基本的JavaBean 以及 mapper文件以及dao
需要jar包:
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><!-- 数据库驱动 --><classPathEntrylocation="D:/sharepackage/mysql-connector-java-5.1.41-bin.jar" /><!-- 一个数据库一个context targetRuntime是指定生成代码的运行时目标 --><!-- MyBatis3是默认值 使用该值,MBG将生成与MyBatis 3.0及更高版本以及JSE 5.0及更高版本兼容的对象--><context id="DB2Tables" targetRuntime="MyBatis3"><!-- 定义注释生成器的属性 --><commentGenerator><!-- 是否生成带注释的时间戳 --><property name="suppressDate" value="true" /><!-- 是否去除自动生成的注释 true:是 : false:否 --><property name="suppressAllComments" value="true" /></commentGenerator><!--数据库链接URL,用户名、密码 --><jdbcConnection driverClass="com.mysql.jdbc.Driver"connectionURL="jdbc:mysql://localhost:3306/test" userId="liujd"password="1234"></jdbcConnection><!-- 用于定义java类型解析器的属性 用于从数据库列信息计算java类型 --><javaTypeResolver><!-- 是否强制对decimal和number字段使用java.math.BigDecimal --><property name="forceBigDecimals" value="true" /></javaTypeResolver><!-- 生成模型的包名和位置 --><javaModelGenerator targetPackage="com.model"targetProject="arithmetic"><!-- 是否在当前路径下新加一层schema --><property name="enableSubPackages" value="true" /><!-- 是否去除从数据库查出的数据两端的空格 --><property name="trimStrings" value="true" /></javaModelGenerator><!-- 生成映射文件的包名和位置 --><sqlMapGenerator targetPackage="com.mapper"targetProject="arithmetic"><!-- 是否在当前路径下新加一层schema --><property name="enableSubPackages" value="true" /></sqlMapGenerator><!-- 生成DAO的包名和位置 --><javaClientGenerator type="XMLMAPPER"targetPackage="com.dao" targetProject="arithmetic"><!-- 是否在当前路径下新加一层schema --><property name="enableSubPackages" value="true" /></javaClientGenerator><!-- 要生成哪些表 --><table tableName="student" domainObjectName="student"enableCountByExample="false" enableUpdateByExample="false"enableDeleteByExample="false" enableSelectByExample="false"selectByExampleQueryId="false"><generatedKey column="id" sqlStatement="JDBC" identity="true" /><!-- domainObjectName将生成的对象名 其他表示是否生成一个Example类 --></table></context></generatorConfiguration>
利用eclipse运行:
右击配置文件 然后点击如下选项就可
阅读全文
0 0
- myBatis自动生成工具
- mybatis自动生成工具
- Mybatis自动生成工具
- mybatis自动生成工具
- mybatis 自动生成工具
- mybatis自动生成工具
- Mybatis 自动生成代码工具
- Mybatis 自动生成代码工具
- mybatis代码自动生成工具
- Mybatis SQLMap自动生成工具
- Mybatis 自动生成代码工具
- mybatis自动生成工具-MBG
- 【Mybatis】自动生成代码工具
- Mybatis generatorConfiguration自动生成工具
- 使用Mybatis自动生成工具
- mybatis代码自动生成工具
- mybatis mybatis-generator 代码自动生成工具
- mybatis mybatis-generator 代码自动生成工具
- iOS 真机上 webview获取html的title无法显示在navigationBar上。title被挤压。解决
- PAT1113 求数集合之差
- mysql api编程(一)
- 基于C#的WinForm窗体美化(无须美工功底)
- 截屏并去掉状态栏
- mybatis自动生成工具
- vue的config文件夹里的index.js详解
- TCP/IP四层模型
- ssh 公钥私钥认证原理
- org.hibernate.AnnotationException: Associations marked as mappedBy must not define database mappings
- 【Linux】模拟实现sleep函数
- 远程主机强迫关闭了一个现有的连接
- Innodb中的事务隔离级别和锁的关系
- mybatis 开发中遇到的问题(一)