一、逆向工程1.1、概述mybatis需要程序号自己编写的SQL。mybatis官方提供了逆向工程,可以针对单表自动生成mybatis执行所需要的代码(mapper,java,maper.一般都是由数据库到java代码, 的生成过程二、导入jar包2.1、mybatis-gene ...
一、逆向工程
1.1、概述
mybatis需要程序号自己编写的SQL。
mybatis官方提供了逆向工程,可以针对单表自动生成mybatis执行所需要的代码
(mapper,java,maper.
一般都是由数据库到java代码, 的生成过程
2.1、mybatis-generator
三、配置
3.1、generatorConfig.
<??><!DOCTYPE generatorConfigurationPUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><generatorConfiguration> <!--指定数据库jar包 --> <classPathEntry location="G:/jar/mysql-connector-java-5.1.37-bin.jar" /> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <!--JDBC连接配置,driver,url,user,password --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/mybatis?character=utf8" userId="root" password="root"> </jdbcConnection> <!--默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- targetProject:生成PO类的位置 --> <javaModelGenerator targetPackage="com.mybatis.po" targetProject=".\src"> <property name="enableSubPackages" value="false" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- targetProject:mapper映射文件生成的位置 --> <sqlMapGenerator targetPackage="com.pb.mybatis.mapping" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true" /> </sqlMapGenerator> <!-- targetPackage:mapper接口生成的位置 --> <javaClientGenerator type=" targetPackage="com.pb.mybatis.mapper" targetProject=".\src"> <!-- enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!--指定要生成的表 --> <table tableName="author"></table> <table tableName="blog"></table> <table tableName="posts"></table> </context></generatorConfiguration>
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:MyBatis入门(七)
关键词:mybatis
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。