在Eclipes里安装Mybaties

一、利用maven配置jar就引入依赖

详情地址

二、手动引入jar包

在这里插入图片描述

三、generatorConfig.xml

1. 运行配置文件就能自动生成pojo和mapper

2. 生成generatorConfig.xml

项目右键→new→other→myba… 下边的文件,next。。。

在这里插入图片描述

配置文件

<?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>

	<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包 -->
	<classPathEntry location="E:\Mybatis\mysql-connector-java-5.1.38.jar" />
	
	<!-- targetRuntime 
		 	MyBatis3 :默认的值,生成基于MyBatis3.X以上版本的内容 包括XXXBySample;
		 	MyBatis3Simpl :类似于MyBatis3 但是不生成XXXBySample -->
	
    <context id="mysql" targetRuntime="MyBatis3Simple">
    
   		<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/pingpang" userId="root" password="1234">
		</jdbcConnection>
		
		<javaTypeResolver>
			<property name="forceBigDecimals" value="false" />
		</javaTypeResolver>
		
		<!-- 设置实体类所在的项目与包的位置 -->
		<javaModelGenerator targetPackage="com.bian.pojo" targetProject="MybatiesTest\src">
			<!-- <property name="enableSubPackages" value="true" />
			<property name="trimStrings" value="true" /> -->
		</javaModelGenerator>
		
		<!-- 生成映射文件的包名和位置 -->
		<sqlMapGenerator targetPackage="com.bian.mapper" targetProject="MybatiesTest\src">
			<!-- <property name="enableSubPackages" value="true" /> -->
		</sqlMapGenerator>
		
		<!-- 生成DAO的包名和位置 -->
		<javaClientGenerator targetPackage="com.bian.mapper" targetProject="MybatiesTest\src" type="XMLMAPPER">
			<!-- <property name="enableSubPackages" value="true" /> -->
		</javaClientGenerator>

		<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名 -->
		<table schema="bian" tableName="adress" domainObjectName="Adress">
			是否使用表中的列表生成类中的成员变量名
			<property name="useActualColumnNames" value="false"/>
		</table> 
		
		<!-- 场地表 -->
		<table schema="pingpang" tableName="field" domainObjectName="Field">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
		
		<!-- 财务表 -->
		<table schema="pingpang" tableName="finance" domainObjectName="Finance">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
		
		<!-- 权限表 -->
		<table schema="pingpang" tableName="rule" domainObjectName="Rule">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
		
		<!-- 角色表 -->
		<table schema="pingpang" tableName="role" domainObjectName="Role">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
		
		<!-- 角色——权限联合查询表 -->
		<table schema="pingpang" tableName="rule_role" domainObjectName="Rule_Role">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
		
		<!-- 开台表 -->
		<table schema="pingpang" tableName="table" domainObjectName="Table">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
		
		<!-- 员工表 -->
		<table schema="pingpang" tableName="user" domainObjectName="User">
			<!-- 是否使用表中的列表生成类中的成员变量名 -->
			<property name="useActualColumnNames" value="false"/>
		</table>
    </context>
</generatorConfiguration>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值