Eclipse配置MyBatis代码自动化功能

栏目: Java · 发布时间: 6年前

内容简介:Eclipse中,Help->Eclipse Marketplace,搜索MyBatis,安装一个扎红头绳小鸟的插件。

阅读更多

1.安装插件

Eclipse中,Help->Eclipse Marketplace,搜索MyBatis,

安装一个扎红头绳小鸟的插件。

2.创建自动化配置文件generatorConfig.xml

新建向导可找到模板,MyBatis->MyBatis Generator Configuration File,可得到一个带有主要配置不需求的模板,再根据自己的情况进行修改。如:

<?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>
  <context id="certTables">
  	<commentGenerator>
  		<property name="suppressAllComments" value="true"/>
  	</commentGenerator>
  	
    <jdbcConnection 
    	connectionURL="jdbc:mysql://127.0.0.1:3306/your_dbname?serverTimezone=Asia/Shanghai" 
    	driverClass="com.mysql.cj.jdbc.Driver" 
    	password="your_passward" 
    	userId="your_userid">
    </jdbcConnection>
    	
    <javaTypeResolver>
    	<property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>
    
    <javaModelGenerator targetPackage="com.wallimn.iteye.sp.asset.bus.cert.model" targetProject="asset">
    	<property name="enableSubPackages" value="false"/>
    	<property name="trimStrings" value="true"/>
    </javaModelGenerator>
    
    <sqlMapGenerator targetPackage="com.wallimn.iteye.sp.asset.bus.cert.model" targetProject="asset">
    	<property name="enableSubPackages" value="false"/>
    </sqlMapGenerator>
    
    <javaClientGenerator targetPackage="com.wallimn.iteye.sp.asset.bus.cert.dao" targetProject="asset" type="XMLMAPPER">
    	<property name="enableSubPackages" value="false"/>
    </javaClientGenerator>
    
     <table tableName="t_c_company"></table>
  </context>
</generatorConfiguration>
3.运行自动代码工具

在配置文件上点右键,Run As,。。。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Spring实战(第4版)

Spring实战(第4版)

Craig Walls 沃尔斯 / 张卫滨 / 人民邮电出版社 / 2016-4-1 / CNY 89.00

《Spring实战(第4版)》是经典的、畅销的Spring学习和实践指南。 第4版针对Spring 4进行了全面更新。全书分为四部分。第1部分介绍Spring框架的核心知识。第二部分在此基础上介绍了如何使用Spring构建Web应用程序。第三部分告别前端,介绍了如何在应用程序的后端使用Spring。第四部分描述了如何使用Spring与其他的应用和服务进行集成。 《Spring实战(第4......一起来看看 《Spring实战(第4版)》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具