当前位置: 首页 > news >正文

Mybatis三剑客(一)在springboot中自动生成Mybatis【generator】

1、pom.xml中新增plugin

    <plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.3.7</version><configuration><overwrite>true</overwrite></configuration></plugin>

2、新建resources/generatorConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfigurationPUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><generatorConfiguration><!--    windows下路径, D:\downloads\xxx.jar--><classPathEntry location="C:\Users\Administrator\Desktop\mysql-connector-java-5.1.6.jar" /><context id="DB2Tables" targetRuntime="MyBatis3"><!--        不再追加xml内容--><plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" /><commentGenerator><property name="suppressAllComments" value="true"/></commentGenerator><jdbcConnection driverClass="com.mysql.jdbc.Driver"connectionURL="jdbc:mysql://127.0.0.1:3306/mall?characterEncoding=utf-8"userId="root"password=""></jdbcConnection><javaTypeResolver ><property name="forceBigDecimals" value="false" /></javaTypeResolver><javaModelGenerator targetPackage="com.imooc.mall.pojo" targetProject="src/main/java"><property name="enableSubPackages" value="true" /><!--            <property name="trimStrings" value="true" />--></javaModelGenerator><sqlMapGenerator targetPackage="mappers"  targetProject="src/main/resources"><property name="enableSubPackages" value="true" /></sqlMapGenerator><javaClientGenerator type="XMLMAPPER" targetPackage="com.imooc.mall.dao"  targetProject="src/main/java"><property name="enableSubPackages" value="true" /></javaClientGenerator><!--        <table tableName="mall_order" domainObjectName="Order" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>--><!--        <table tableName="mall_order_item" domainObjectName="OrderItem" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>--><!--        <table tableName="mall_user" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>--><!--        <table tableName="mall_category" domainObjectName="Category" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/>--><!--        <table tableName="mall_product" domainObjectName="Product" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false">--><!--            <columnOverride column="detail" jdbcType="VARCHAR" />--><!--            <columnOverride column="sub_images" jdbcType="VARCHAR" />--><!--        </table>--><table tableName="mall_shipping" domainObjectName="Shipping" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"/></context>
</generatorConfiguration>

注意:

        context 中内容是有顺序的

        commentGenerator在前面s

3、idea中的terminal中执行mybatis自动生成命令 

mvn mybatis-generator:generate

http://www.lryc.cn/news/121979.html

相关文章:

  • 【LeetCode 热题 100】图论 专题(bfs,拓扑排序,Trie树 字典树)
  • Jmeter压测实战:Jmeter二次开发之自定义函数
  • 在python中使用nvidia的VPF库对RTSP流进行硬解码并使用opencv进行显示
  • C++中using namespace std的作用记录
  • 【TX 企业微信私有化历史版本 API 信息泄露】
  • 腾讯云轻量应用服务器镜像应用模板清单大全
  • C语言链表操作
  • 详解拦截器和过滤器
  • 关于`IRIS/Caché`进程内存溢出解决方案
  • 构建Docker容器监控系统(cadvisor+influxDB+grafana)
  • 最强自动化测试框架Playwright(17)- 模拟接口
  • Python爬虫——requests_get请求
  • 【EI复现】一种建筑集成光储系统规划运行综合优化方法(Matlab代码实现)
  • C++11 异步与通信之 std::async
  • 影视站用什么cms好?
  • HOT88-乘积最大子数组
  • 工博士与纷享销客达成战略合作,开启人工智能领域合作新篇章
  • 拆解与重构:慕云游首页组件化设计
  • 刷了3个月的华为OD算法题,刷出感觉了,如洁柔般丝滑,文末送《漫画算法2:小灰的算法进阶》
  • ip转换器哪个好用 ip地址切换器有哪些
  • 【python】爬取豆瓣电影Top250(附源码)
  • 35岁职业危机?不存在!体能断崖?不担心
  • C语言——指针进阶
  • heap pwn 入门大全 - 1:glibc heap机制与源码阅读(上)
  • 树莓派RP2040 用Arduino IDE安装和编译
  • 云安全攻防(八)之 Docker Remote API 未授权访问逃逸
  • 2023-08-13 LeetCode每日一题(合并两个有序数组)
  • nbcio-boot升级springboot、mybatis-plus和JSQLParser后的LocalDateTime日期json问题
  • 「C/C++」C/C++搭建程序框架
  • Android 内存泄漏