1.创建学生信息表

create table stu(id int unsigned primary key auto_increment comment 'ID',name varchar(100) comment '姓名',age tinyint unsigned comment '年龄',gender tinyint unsigned comment '性别, 1:男, 2:女',score double(5,2) comment '成绩',phone varchar(11) comment '手机号'
)comment '学生表';
ALTER TABLE stu CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
insert into stu(id, name, age, gender,score, phone) VALUES (null,'张三',18,'1',560,'18800000000');
insert into stu(id, name, age, gender,score, phone) VALUES (null,'李四',19,'1',572,'18800000001');
insert into stu(id, name, age, gender,score, phone) VALUES (null,'王五',20,'1',480,'18800000002');
insert into stu(id, name, age, gender,score, phone) VALUES (null,'赵六',18,'2',621,'18800000003');
insert into stu(id, name, age, gender,score, phone) VALUES (null,'黄七',17,'2',211,'18800000004');
insert into stu(id, name, age, gender,score, phone) VALUES (null,'孙八',18,'1',492,'18800000005');

2.创建项目工程

在这里插入图片描述
在这里插入图片描述

2.appliction.yml

spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/mybatisusername: rootpassword: 1234

3.StuController

package com.itdanb.springboottest.controller;import com.itdanb.springboottest.pojo.Stu;
import com.itdanb.springboottest.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class StuController {@Autowiredprivate StuService stuService;@RequestMapping("/findById")public Stu findById(Integer id){return stuService.findById(id);}
}

Stumapper

package com.itdanb.springboottest.mapper;import com.itdanb.springboottest.pojo.Stu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;@Mapper
public interface StuMapper {@Select("select * from stu where id = #{id}")public Stu findById(Integer id);}

Stu

package com.itdanb.springboottest.pojo;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@AllArgsConstructor
@NoArgsConstructor
public class Stu {private Integer id;private String name;private Integer age;private Short gender;private String score;private String phone;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}public Short getGender() {return gender;}public void setGender(Short gender) {this.gender = gender;}public String getScore() {return score;}public void setScore(String score) {this.score = score;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}@Overridepublic String toString() {return "Stu{" +"id=" + id +", name='" + name + '\'' +", age=" + age +", gender=" + gender +", score='" + score + '\'' +", phone='" + phone + '\'' +'}';}
}

StuService

package com.itdanb.springboottest.service;import com.itdanb.springboottest.pojo.Stu;public interface StuService {public Stu findById(Integer id);
}

StuServiceImpl

package com.itdanb.springboottest.service.impl;import com.itdanb.springboottest.pojo.Stu;
import com.itdanb.springboottest.mapper.StuMapper;
import com.itdanb.springboottest.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;@Service
public class StuServiceImpl implements StuService {@Autowiredprivate StuMapper stuMapper;@Overridepublic Stu findById(Integer id) {return  stuMapper.findById(id);}
}

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/diannao/91896.shtml
繁体地址,请注明出处:http://hk.pswp.cn/diannao/91896.shtml
英文地址,请注明出处:http://en.pswp.cn/diannao/91896.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

关于transformer的一些疑点总结

残差连接的作用 Transformer中的残差连接(Residual Connection)是其深层架构能稳定训练的核心设计之一,主要通过以下机制发挥作用: 1. 缓解梯度消失,支持深层训练 梯度保护机制:在反向传播时,…

【终极指南】解决 Windows 11 更新后 Docker 连接 localhost 奇慢(卡顿、超时十几秒)的通用方案

聪明人能看得出这是 ai 写的,但也是我亲身实践的,最后让 ai 总结写了一篇,放心食用 一、 结论先行(直接用)问题现象: 升级到某个 Windows 11 版本后,在本地访问 Docker 容器中部署的任何服务&am…

Stream API

Java 8 引入的 Stream API 是处理集合数据的强大工具,它允许你以声明式方式处理数据集合,支持各种聚合操作和并行处理。以下是 Stream API 的核心知识点及具体代码示例: 1. Stream 概述 Stream 是数据渠道,用于操作数据源&#xf…

相机参数的格式与作用

在计算机视觉中,相机标定是非常重要的一步,主要目的是从图像中恢复出物体的三维信息。为了做到这一点,我们需要了解和使用一系列的数学工具,这些工具描述了相机的成像过程,包括相机的内参、外参、畸变系数、投影矩阵和…

【jvm|基本原理】第四天

摘要:本文简单分析了Java虚拟机的核心运行机制。首先介绍了基本数据类型在32位和64位虚拟机中的存储差异,说明slot槽设计以空间换时间的优化思路。其次详细解析了对象在堆内存中的存储结构,包括对象头、对象数据和对齐填充机制。然后探讨了方…

Git高级操作与最佳实践详解

前言 熟练掌握Git的高级操作可以显著提高开发效率,优化工作流程,解决复杂问题。本文将详细介绍Git的高级操作技巧与最佳实践,帮助开发者更加高效地管理代码和协作开发。 1. 提交历史管理 1.1 修改最近的提交 # 修改最近的提交信息 git co…

ElasticSearch:商品SKU+SPU实现join查询,设计及优化

文章目录一、SPUSKU1、商品SPU和SKU2、SPU和SKU的关系3、实现SPUSKU父子嵌套查询1. **嵌套对象(Nested Objects)**2. **父子关系(Parent-Child)**3. **应用层关联(Application-Side Join)**(推荐…

Objective-c 初阶 —— Runtime(方法交换 消息传递)

一、消息传递1、什么是消息[a func1];我们会把这种用方括号来调函数的方式称为发消息。对于这个例子,就相当于我们给 a 这个对象发了个 func1 的消息(个人认为指令更好理解)。2、什么是 selectorselector 就是一个函数区分器。它只会给这个方…

【计算机网络架构】树型架构简介

引言在当今数字化时代,网络架构如同复杂的神经系统,支撑着各种信息的流通与交互。从个人日常的网络浏览、在线购物,到企业的远程办公、数据存储,再到国家层面的政务信息化、智慧城市建设,网络架构都扮演着不可或缺的角…

llama-factory快速开始

llama-factory快速开始 文章目录llama-factory快速开始前言一、环境配置1.1 训练顺利运行需要包含4个必备条件1.2 llama-factory下载1.3 环境下载1.4 硬件环境校验二、启动前言 https://github.com/hiyouga/LLaMA-Factory/blob/main/README_zh.md这是GitHub中文介绍文档&#…

408数据结构强化(自用)

常用代码片段&#xff08;持续更新&#xff09;折半查找void SearchBinary(int A[];int x){int low 0, high n-1, mid;while(low<high){mid (lowhigh)/2;if(A[mid]x) break;else if(A[mid] < x) low mid 1;else high mid - 1;}顺序表逆置void Reverse(SqList &…

linux cpu频率和AVS调压等级

1&#xff0c;linux常见的cpu频率对应的电压等级对应参数表如下:频率&#xff08;GHz&#xff09;电压&#xff08;V&#xff09;1.61.41.41.21.21.01.00.82&#xff0c;avs调压的几种方式linux内核宏解释Linux内核中&#xff0c;AVS调压的实现依赖于一些宏定义和配置选项&…

Input输入和Screen相关

知识点using System.Collections; using System.Collections.Generic; using UnityEngine;public class Lesson11 : MonoBehaviour {// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){#region 注意&#xff0c…

如何在CSDN变现?如何赚钱?如何涨粉?如何找到优质大V博主合作伙伴?

&#x1f525; 2025最新 如何在CSDN变现&#xff1f;如何赚钱&#xff1f;如何跟对人&#xff1f;如何找到优质博主合作伙伴&#xff1f; 大家好&#xff0c;我是猫头虎&#xff0c;今天✍️想和大家聊聊在CSDN平台变现的问题。这也是绝大多数伙伴非常关心的一个话题——其实&…

OpenCV特征点提取算法orb、surf、sift对比

下面是 OpenCV 中三种常用特征点提取算法&#xff1a;ORB、SURF 和 SIFT 的详细对比&#xff0c;从 算法原理、性能、使用限制 和 适用场景 多维度进行总结&#xff0c;帮助大家在实际项目中合理选择。一览表&#xff1a;ORB vs. SURF vs. SIFT属性/算法ORBSURFSIFT全称Oriente…

LeafletJS 与 React:构建现代地图应用

引言 LeafletJS 是一个轻量、灵活的 JavaScript 地图库&#xff0c;广泛用于创建交互式 Web 地图&#xff0c;而 React 作为现代前端框架&#xff0c;以其组件化、状态管理和虚拟 DOM 特性&#xff0c;成为构建动态用户界面的首选工具。将 LeafletJS 与 React 结合&#xff0c…

前后端数据交互,关于表单数据传输问题

表单提交var formData new FormData(); // 添加每个事故ID作为单独的参数 accidentIds.forEach(id > formData.append(accidentIds, id)); formData.append(status, statusText); $.messager.confirm(确认, 确定要将事故记录标记为 statusText 吗&#xff1f;, function …

新书推介 | 吉林大学出版教材《汽车智能辅助驾驶系统技术》,国产仿真工具链GCKontrol-GCAir教学应用

近日&#xff0c;吉林大学出版了由高镇海教授、孙天骏副教授主编的新教材《汽车智能辅助驾驶系统技术》&#xff0c;本书系统地介绍了汽车智能辅助驾驶系统的发展需求、物理架构、功能算法、技术原理以及应用场景。在教材第17章《仿真测试》&#xff0c;应用国产化GCKontrol-GC…

从 0 到 1 玩转 XSS - haozi 靶场:环境搭建 + 全关卡漏洞解析

文章目录前言靶场地址0X00 直接注入0X01 闭合标签10X02 闭合标签20X03 绕过特殊符号10X04 绕过特殊符号20X05 绕过注释符0X06 绕过更多符号0X07 绕过更多符号20X08 绕过闭合符号0X09 绕过URL匹配0X0A 绕过URL过滤0X0B 绕过大写转换10X0C 绕过大写转换20X0D 绕过注释0X0E 古英语…

TF卡格式化

cmd 输入diskpart,在新打开的窗口输入list disk&#xff0c;然后select disk [磁盘号]&#xff0c;clean&#xff0c;回车变成未分区的。再选中磁盘&#xff0c;选中之后create partition [分区名] 回车&#xff0c;list partition&#xff0c;查看分区&#xff0c;输入active&…