springboot整合mybatis | Spring Boot 4

🍅 作者简介:哪吒,CSDN2021博客之星亚军🏆、新星计划导师✌、博客专家💪

🍅 哪吒多年工作总结:Java学习路线总结,搬砖工逆袭Java架构师

🍅 关注公众号【哪吒编程】,回复1024,获取Java学习路线思维导图、大厂面试真题、加入万粉计划交流群、一起学习进步

目录

一、前言

二、mybatis-spring-boot-starter

三、无配置注解版

1、添加maven文件

2、application.yml添加相关配置

3、controller

4、开发mapper

5、运行

(1)查询

(2)插入

四、极简XML版本

1、配置

2、employeeMapper.xml

3、开发mapper

五、两种模式如何选择


一、前言

Orm框架的本质是简化编程中操作数据库的编码,发展到现在,基本上就剩宣称不用谢一句sql的hibernate,一个是可以灵活调试动态sql的mybatis,两者各有特点,在企业级系统来发中可以根据需求灵活使用。发现一个有趣的现象:传统企业大都喜欢hibernate,互联网行业通常使用mybatis。

hibernate特点就是所有的sql都用java代码来生成,不用跳出程序去写sql,有这编程的完整性,发展到最顶端就是spring data jpa这种模式,基本上根据方法名就可以生成对应的sql。

mybatis初期使用比较麻烦,需要各种配置文件、实体类、Dao层映射关系、还有一大堆其他配置文件。

当然mybatis也有发现了这种弊端,初期开发了generator可以根据表结构自动生成实体类、配置文件和dao层代码,可以减轻一部分开发量;后期也进行了大量的优化可以使用注解,自动管理dao层和配置文件等,发展到最顶级就是今天讲的这种springboot+mybatis可以完全注解不用配置文件,也可以简单配置轻松上手。

springboot就是牛逼呀,啥玩意关联springboot都能化繁为简。

二、mybatis-spring-boot-starter

mybatis-spring-boot-starter主要由两种解决方案,一种是使用注解解决一切问题,

SpringBoot4与Spring7发布:云原生深度进化 Spring Boot 4和Spring Framework 7带来基础要求升级、模块化改进、API版本化、声明式HTTP客户端、弹性注解等重大特性,标志着Java开发生态向云原生时代的深度进化。近日,Spring生态迎来了自2022年以来最具里程碑意义的更新——Spring Boot 4和Spring Framework 7的正式发布。 阅读详情

相关推荐

Spring Boot 3 专栏:Spring Boot 3.4.0 整合 Mybatis-plus 和 Mybatis

Mybatis 和 Mybatis-plus 作为 Java 生态中广泛使用的 ORM 框架,在 Spring Boot 项目中有着极高的使用率。本文将详细介绍如何在 Spring Boot 3.4.0 项目中同时整合 Mybatis 和 Mybatis-plus,并展示它们的协同工作方式。@Data@TableName("t_user") // Mybatis-plus 注解@TableId(type = IdType.AUTO) // Mybatis-plus 主键策略。

lssffy的博客 1875

保姆级教程:用Docker一键部署vLLM大模型推理服务(附常见报错解决方案)

本文提供了一份详细的Docker化vLLM大模型推理服务部署指南,涵盖从环境准备到性能调优的全流程。通过容器化技术解决大语言模型部署中的显存利用率、吞吐量等核心问题,并附常见报错解决方案,帮助开发者快速构建高效、可扩展的AI推理服务。

weixin_29248313的博客 494

Keil MDK 5.37及之后版本 安装AC5(ARMCC)编译器详细步骤

由于Keil 5.37及之后版本不再默认安装AC5(ARMCC)编译器,这就会导致由AC5编译的工程无法正常编译,往往输出窗口会提示以下信息:*** Target ‘STM32xxxx‘ uses ARM-Compiler ‘Default Compiler Version 5‘ which is not available.

s_Modesto的博客 1万+

保姆级避坑指南:在Win10/Win11上搞定西门子博图V17完整安装(附注册表清理技巧)

本文提供了一份详细的西门子博图V17在Win10/Win11系统上的安装指南,涵盖从系统预检、注册表清理到分步安装的全过程。特别针对常见的安装失败问题,如PendingFileRenameOperations注册表残留和.NET Framework 3.5未启用等,提供了专业的解决方案和避坑技巧,帮助用户高效完成安装并优化性能。

weixin_29240711的博客 948

如何在STM32上5分钟搞定nanopb协议传输?附完整代码示例

本文提供了在STM32微控制器上快速集成nanopb协议传输的实战指南。通过详细的步骤,从.proto文件定义、代码生成到STM32CubeIDE项目移植,帮助开发者利用nanopb这一轻量级Protocol Buffers C语言实现,在5分钟内构建高效、跨平台的嵌入式设备通信框架,并附有完整的代码示例。

jwt8token的博客 841

C++和OpenGL实现3D游戏编程【连载6】——不规则图形的纹理贴图(附源码)

上一节我们讨论了纹理贴图的相关基础操作,但上一节的纹理贴图操作基本上都是规则图形,包括圆形和球形虽然复杂一点,但是它也是规则的。这一节课我们要讨论一下,怎么在不规则图形上纹理贴图,就比如文章下图的心形纹理贴图,以及纹理的平移、旋转、放大缩小功能。

zhooyu的博客 1309

基于YOLOv11的农作物病虫害检测系统设计与实现

我们使用公开的IP102病虫害数据集作为基础,该数据集包含102种病虫害类别,覆盖水稻、小麦、玉米等多种主要农作物。图像数量:75,222张类别数:102图像分辨率:从640×480到4000×3000不等标注格式:PASCAL VOC格式此外,我们还收集了部分田间实际拍摄的图像以增强模型泛化能力。

YOLO 596

6、哈代空间、算子函数及相关概念解析

本文深入探讨了数学中哈代空间与算子函数的核心概念,包括强函数的因式分解、半单零点的定义与性质、Blaschke-Potapov乘积的存在性、Nagy-Foias模型算子的结构与谱分析、可数集合的相关性质(如Carlesonian集合、稀有集合等)、简单分式族的可分性与基性质,以及指数型整函数的增长特性。文章还分析了这些数学对象之间的内在联系,并通过图表与表格形式直观呈现了集合性质与函数空间结构的关系。这些理论不仅在数学分析和泛函分析中具有重要意义,也在信号处理、量子力学等应用领域具有广泛价值。

yhn4567890的博客 171

几种常见的Web攻击

几种常见的Web攻击 文章目录几种常见的Web攻击一、DoS攻击1.SYN洪水攻击2.IP欺骗3.Land攻击4.针对DoS攻击的防御二、CSRF攻击1. CSRF攻击的发生有三个必要条件:2.几种防护方法:三、XSS漏洞攻击1.非持久型XSS漏洞2.持久型XSS漏洞四、SQL注入1.SQL注入的危害2.SQL注入的方式3.防止SQL注入的解决方案 一、DoS攻击 DoS(Denial of Service),拒绝服务,顾名思义这种攻击是为了让服务器无法提供正常服务,最常见的DoS攻击是网络带宽攻击和连

wolfGuiDao的博客 1261

深度学习工具包 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")

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

上一篇: 【Docker 2】看完这篇,Docker你就入门了
下一篇: Thymeleaf的基本语法 | Spring Boot 3
哪 吒
哪 吒 2022年度博客之星TOP 1 2022年度博客之星TOP 1 领域专家: 后端开发技术领域 领域专家: 后端开发技术领域
博客等级 码龄9年 59万+粉丝 2962原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

哪 吒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值