mybatis 代码生成

MyBatis自定义代码生成策略实战 MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解进行配置和原始映射,将接口和 Java 的 POJOs(Plain Old Java Objects, 普通的 Java 对象)映射成数据库中的记录。在生成MyBatis的Mapper XML文件时,我们通常会定义一些SQL片段,这些片段可以在多个SQL语句中复用。 阅读详情

1.需要jar包

        <dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>8.0.15</version>
		</dependency>
		<dependency>
			<groupId>org.mybatis.generator</groupId>
			<artifactId>mybatis-generator-core</artifactId>
			<version>1.3.7</version>
		</dependency>

2.配置文件

<?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="mysql-connector-java-8.0.15.jar"/>
    <context id="DB2Tables"    targetRuntime="MyBatis3">
        <commentGenerator>
            <property name="suppressDate" value="true"/>
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--数据库链接地址账号密码-->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test?characterEncoding=utf-8&amp;useSSL=false&amp;serverTimezone=Hongkong" userId="root" password="root">
        </jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false"/>
        </javaTypeResolver>
        <!--生成Model类存放位置-->
        <javaModelGenerator targetPackage="knife.model" targetProject="src">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!--生成映射文件存放位置-->
        <sqlMapGenerator targetPackage="knife.mapping" targetProject="src">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <!--生成Dao类存放位置-->
        <javaClientGenerator type="XMLMAPPER" targetPackage="knife.dao" targetProject="src">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <!--生成对应表及类名-->
        <table tableName="test" domainObjectName="Test" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
    </context>
</generatorConfiguration>

3.命令

java -jar mybatis-generator-core-1.3.7.jar -configfile config.xml -overwrite

4.文件目录

5.生成代码目录

MyBatis 自动代码生成插件实战指南 MyBatis 是一个流行的 Java 持久层框架,它为数据持久化提供了灵活的方式。它通过使用简单的 XML 或注解配置,将对象与数据库表映射起来,极大地简化了数据访问代码。MyBatis 源于 Apache 的另一个项目 iBatis,但随着时间的推移,iBatis 被重构并命名为 MyBatis。MyBatis Generator (MBG) 是一个强大的代码生成工具,它可以大大简化开发工作,特别是在数据库操作代码的生成方面。 阅读详情

相关推荐

CCC数字钥匙3.0标准解读(16)

介绍通信过程最重要部分:身份认证和加密.介绍需要身份认证的过程和需要加密的数据及过程.

weixin_41738640的博客 1531

Mybatis代码生成

导入 mybatis-plus-generator 依赖

m0_54799077的博客 53

头歌平台 操作系统课堂练习2.3:系统调用

使用 gdb 调试内核,跟踪到 main 函数入口的方法与之前实训一样。系统运行时,执行的前 3 个系统调用的编号和名字分别是什么?系统运行时,执行的前 3 个系统调用的编号和名字分别是什么?本关卡使用版本 1 内核进行分析,版本 1 内核文件存放在。为了完成本关任务,你需要:跟踪系统调用的发生。此时,系统调用号存放在寄存器 eax 中。

lazbuyaotoutu的博客 2万+

MyBatis代码生成工具

写了一个网页版的MyBatis代码生成工具,可以自定义列。 地址: https://github.com/Youmoo/mybatis-generator 欢迎提需求。

Youmoo的专栏 1321

LabVIEW实战:3步搞定Excel模板数据填充(附完整VI源码)

本文提供了一个高效的LabVIEW Excel报表自动化方案,通过使用命名区域定位和动态文件管理,实现数据的精准、动态填充。文章详细阐述了如何构建可复用的数据填充引擎,包括文本、表格数据及图表的写入,并分享了主程序流程、错误处理及性能优化等进阶技巧,帮助工程师彻底摆脱手动操作,提升工作效率。

weixin_29233333的博客 276

【验证技能树】UVM 源码解读01 -- UVM本质上就是软件工程方法论在芯片验证领域的应用

文章摘要: UVM(通用验证方法学)是基于SystemVerilog的芯片验证框架,采用组件化、面向对象和事务级抽象设计。其核心在于职责分离与数据流,通过Driver、Monitor、Sequencer等模块协作实现高效验证。UVM强调复用性、可扩展性和可维护性,类似软件工程的模块化与低耦合原则。理解其体系结构比记忆API更重要,有助于灵活组合组件并提升验证效率。UVM不仅是工具,更融合了软件工程思维,推动验证工作向自动化、系统化发展。掌握UVM底层逻辑能优化验证环境设计,适用于从IP到SoC的多层级验证场

qq_45869788的博客 1039

代码生成_Mybatis

代码生成_Mybatis依赖pom.xml配置文件数据库配置基本配置配置源码实体类工具类主方法 依赖pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.a...

一叶知秋 141

WIFI基础入门--802.11g--增强速率物理层ERP--15

WIFI基础入门--802.11--增强速率物理层--191.802.11g的组件保护机制 1.802.11g的组件 802.11g其实是将好几种物理层规范合而为一。虽然统称为增强速率物理层(Extended Rate PHY简称ERP),但是实际上ERP有好几种不同的方式: ERP-DSSS与ERP-CCK 这两种模式向下兼容于原始直接序列规范(1Mbps与2Mbps),以及所提到的802.11...

香蕉一号 4617

MyBatis-Flex代码生成

MyBatis-Flex代码生成

道友,山高路远,如果找不到答案就去找自己。 648

LVGL的基础知识总结

另外,还有自定义字库的使用,具体可参考开发手册。

qq_28576837的博客 7386

爬虫小例--爬药监局(上)

”明月如霜,好风如水,清景无限 “ 文远最近也算是爬虫入门吧,相信后面会慢慢熟悉。 壹 直接上例子,爬取药监局的数据。目的是得到每家公司的详情数据,例: 具体网址:http://scxk.nmpa.gov.cn:81/xk/ 这是主页,下面详情信息: 贰 分析,通过网页检查发现,主网页上没有公司相关数据,观察XHR中的Ajax请求发现,公司信息都是动态数据(方便更新),点击发现每个公司 的详情信息通过ID号这个参数区别,那么可以确定思路是先得到每个公司的ID号,然后在通过ID对应每一个详细网站,同样右键

john_ashley的博客 4556

Mybatis代码生成javaConfig配置

** Mybatis代码生成javaConfig配置 ** 关于mybatis的代码生成已经有多不胜数的文章和例子,本文主要介绍通过javaConfig的方式替代xml的方式配置,从而以接口的形式完成参数化的代码生成。 一、环境 Idea, JDK8, springboot2.2.2, mysql8.0.13 关键包及版本: Mysql驱动: mysql-connector-java-8.0.1...

qq_35317619的博客 1880

新手避坑指南:HT7036计量芯片SPI读取电压的完整流程(从复位到校准)

本文详细介绍了HT7036计量芯片的SPI读取电压完整流程,从硬件准备到校准设置,重点解析了复位引脚处理、SPI通信配置、芯片初始化及数据处理等关键步骤。针对常见问题如晶振焊接、SPI时序错误等提供实用解决方案,帮助开发者高效完成电压测量与校准。

weixin_30070339的博客 326

MyBatis-Plus代码生成工具

mybatis代码生成器

qq_41700208的博客 653

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

MyBatis Generator 代码生成模板

MyBatis Generator 代码生成模板 【下载地址】MyBatisGenerator代码生成模板 `mybatis-generator.zip` 是一个高效的工具包,专为简化 MyBatis 开发流程而设计。它能够自动生成数据库表对应的 MyBatis 映射文件、Java 实体类以及 Mapper 接口,显著提...

gitblog_06726的博客 334

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

mybatis代码生成神器

/ // .controller("controller")//控制层包名。// //.addTablePrefix("sys_")//设置表前缀过滤。// .service("service")//service层包名。// //.other("dto")//生成dto目录 可不用。

m0_73098024的博客 299

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

mybatis代码生成插件

第一步:在项目的pom文件中加入插件(build元素下) <build> <plugins> <!--mybatis自动生成代码插件--> <plugin> <groupId>org.mybatis.generator</groupId&...

qq_45452299的博客 186

Mybatis可视化代码生成工具

公司大佬让调研一下 mybatis-generator-gui ,这是一款开源图形化 MyBatis 代码生成工具,使用起来相当的方便好用!推荐给在开发道路上的小伙伴们: GutHub 地址:https://github.com/zouzg/mybatis-generator-gui 使用 Git 克隆到本地,然后可直接导入开发工具 Eclipse 或者 IDEA 中使用: Git 的安装与...

这里记录着我一点一滴的进步 1119

mybatis- generator代码生成配置及达梦的代码生成问题

mybatis- generator代码生成配置及达梦的代码生成问题

白也白 3308

基于Oracle的mybatis-plus及mybatis代码生成

基于Oracle的mybatis-plus及mybatis代码生成 在做一般项目的时候可以利用代码生成插件,快速搭建基于mvc模式的代码,提高开发效率,下面是我常用的两种插件 一、mybatis-plus代码生成 引入依赖 <!--mybatis-plus--> <dependency> <groupId>com.baomidou</groupId> <artifactId&gt

qq_45299533的博客 995

mybatis-plus代码生成工具

全局覆盖已有文件的配置已失效,已迁移到策略配置中

haohaounique的博客 2609

Mybatis Mybatis-plus 逆向代码生成

Mybatis 和 Mybatis-plus 逆向代码生成源码。 gitee源码路径: Mybatis :https://gitee.com/wt007/generator-sqlmap-custom.git Mybatis-plus:https://gitee.com/wt007/mybatis-plus-generator.git 新人不足,不喜勿喷,若有借鉴,还望海涵! ...

xtwu007的博客 526

mybatis代码生成的几种方式

mybatis代码生成工具mybatis-generator调用有好几种方式:1. 使用eclipse插件,在下面地址安装 http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite/ 然后编写生成配置文件generatorConfig.xml,eclipse中在这个文件上右键,就有Gene

u011679955的博客 383

MyBatis可视化代码生成工具

项目使用了 mybatis-generator-gui ,这是一款开源图形化 MyBatis 代码生成工具,使用起来相当的方便好用!推荐给在开发道路上的小伙伴们。

刘鹏博的博客 1万+
上一篇: springboot @Aspect用法
下一篇: windows 安装 rabbitmq
knife1220
博客等级 码龄15年 33粉丝 176原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值