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

使用 SpringBoot 基础web开发的支持

首先导入项目相关的依赖:

pom.xml 文件: 导入相关项目依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.3.3</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.ty</groupId><artifactId>SpringBootWeb</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><name>SpringBootWeb</name><description>SpringBootWeb</description><url/><licenses><license/></licenses><developers><developer/></developers><scm><connection/><developerConnection/><tag/><url/></scm><properties><java.version>21</java.version></properties><dependencies><!--    导入jquery包    --><dependency><groupId>org.webjars</groupId><artifactId>jquery</artifactId><version>3.7.1</version></dependency><!--   SpringBoot热部署支持(开发阶段使用)  --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency><!--   导入 jstl标签依赖库     -->
<!--        <dependency>-->
<!--            <groupId>javax.servlet</groupId>-->
<!--            <artifactId>javax.servlet-api</artifactId>-->
<!--            <version>3.1.0</version>-->
<!--        </dependency>--><dependency><groupId>jakarta.servlet</groupId><artifactId>jakarta.servlet-api</artifactId></dependency><!--   添加jsp引擎依赖   --><dependency><groupId>org.apache.tomcat.embed</groupId><artifactId>tomcat-embed-jasper</artifactId></dependency><!-- 导入 mybatis-plus 包 --><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId><version>3.5.7</version></dependency><!--    导入jpa包    --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><!-- 导入 junit 测试包      --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency><!--        &lt;!&ndash;    导入mysql包    &ndash;&gt;-->
<!--        <dependency>-->
<!--            <groupId>mysql</groupId>-->
<!--            <artifactId>mysql-connector-java</artifactId>-->
<!--            <version>8.0.19</version>-->
<!--        </dependency>--><!--  导入 阿里巴巴的 Druid 数据源 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.22</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build></project>

在启动类加bean 的扫描:

application.properties 配置文件:

spring.application.name=SpringBootWebspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/crm?serverTimezone=GMT-8
spring.datasource.username=root
spring.datasource.password=whsspring.datasource.type=com.alibaba.druid.pool.DruidDataSourcespring.datasource.druid.initial-size=3
spring.datasource.druid.min-idle=3
spring.datasource.druid.max-active=10
spring.datasource.druid.max-wait=60000
spring.datasource.druid.stat-view-servlet.login-username=root
spring.datasource.druid.stat-view-servlet.login-password=whs
spring.datasource.druid.filter.stat.log-slow-sql=true
spring.datasource.druid.filter.stat.slow-sql-millis=2000# 打印sql
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl# 指定SpringMvc视图的前缀和后缀 , 使其支持使用Jsp文件作为视图
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp# 关闭Thymeleaf
spring.thymeleaf.cache=true
# 热部署配置
spring.devtools.restart.enabled=true  
spring.devtools.restart.additional-paths= src/main/java 
spring.devtools.restart.exclude=static/**,public/**

流程:

1. 在 mappr 层 继承BaseMapper

2. UserService 中定义自己另外需要的接口 

public interface UserService {public User login(String username, String password);public int addUser(User user);public int updateUser(User user);public int deleteUser(Long usrId);public User getUser(Long usrId);public List<User> findAllUsers();
}

3. UserServiceImpl 实现方法:

4. 编写  UserController 控制器类 :

5. 在浏览器进行访问

最后一个简单的 使用 SpringBoot 基础web开发的支持 就已经完成了。

相关文章:

使用 SpringBoot 基础web开发的支持

首先导入项目相关的依赖&#xff1a; pom.xml 文件&#xff1a; 导入相关项目依赖 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-in…...

nature reviews genetics | 细胞互作和通讯方法总结

–https://doi.org/10.1038/s41576-023-00685-8 The diversification of methods for studying cell–cell interactions and communication 留意更多内容&#xff0c;欢迎关注微信公众号&#xff1a;组学之心 研究团队和研究单位 细胞间相互作用的前沿进展&#xff1a;从转…...

AI 浪潮中的一体化数据库|外滩大会之OceanBase实录

2024 年 9 月 5 日至 7 日&#xff0c;在上海黄浦世博园区&#xff0c;“2024 Inclusion 外滩大会”盛大举行。期间&#xff0c;9月6日&#xff0c;由OceanBase携手赛迪顾问共同策划并主办了 “AI浪潮中的分布式数据库&#xff1a;探索行业增长新动能与关键业务负载实践”。本…...

Qt自定义按键实现长,短按

本文介绍Qt自定义按键实现长&#xff0c;短按。 Qt触摸屏应用有时会涉及到触摸屏按钮长&#xff0c;短按操作&#xff0c;如长按实现关机操作&#xff0c;本文基于普通QPushButton为基类&#xff0c;自定义按键实现长&#xff0c;短按操作。 1.定义新类 这里以QPushButton为…...

禁用win10的自动更新功能

禁用win10自动更新的方法&#xff1a; 方法1&#xff1a;系统设置 开始->设置&#xff08;win i&#xff09;->更新和安全->高级选项->暂停更新&#xff08;只能暂停35天&#xff09; 方法2&#xff1a;服务 开始->运行&#xff08;win r&#xff09;->s…...

机器学习 第12章 计算学习理论

目录 基础知识PAC学习有限假设空间可分情形不可分情形 VC维稳定性 基础知识 计算学习理论研究的是关于通过"计算"来进行"学习"的理论&#xff0c;即关于机器学习的理论基础&#xff0c;其目的是分析学习任务的困难本质&#xff0c;为学习算法提供理论保证…...

【雅特力AT32】外部中断事件控制器EXINT(附源码解析)

基础概念弄懂了之后&#xff0c;对于实际开发中断初始化流程和寄存器查阅是很重要的。 1.EXINT介绍 2.功能描述和配置流程 中断初始化流程☆ ​ 1>选择中断源 ​ 2>选择触发方式 ​ 3>使能中断或事件 ​ 4>产生软件触发 ​ 中断清除流程 ​ 其他注意点 3.EXINT寄存…...

Redis集群_cluster

cluster集群 cluster翻译就是集群&#xff0c;所以cluster集群也叫做redis集群相比于哨兵模式&#xff0c;cluster集群能支持扩容&#xff0c;并且无需额外的节点来监控状态&#xff0c;所以使用这种模式集群的系统会用的更多些redis cluster采用的是去中心化网络拓扑架构&…...

jdk相关介绍

JDK&#xff0c;全称Java Development Kit&#xff0c;是Java语言开发的基础工具包。它包含了Java运行时环境&#xff08;JRE&#xff09;以及用于开发Java应用程序的各种工具和库。JDK为Java程序员提供了编译、调试和运行Java应用程序所需的全部环境。 JDK的主要组成部分包括&…...

【GoMate框架案例】讯飞大模型RAG智能问答挑战赛top10 Baseline

【RAG框架】GoMate&#xff1a;RAG Framework within Reliable input,Trusted output 【项目链接】&#xff1a;https://github.com/gomate-community/GoMate 一、赛题背景 RAG&#xff08;检索增强生成&#xff09;是一种结合了检索模型和生成模型的技术&#xff0c;它通过检…...

2024/9/15 408“回头看”之应用层小总结(下)

域名系统DNS: 本地域名服务器 本地域名服务器起着代理的作用&#xff0c;会将报文转发到根域名服务器、顶级域名服务器、权限域名服务器。 递归查询&#xff1a; 迭代查询&#xff1a; 文件传送协议FTP: FTP客户和FTP服务器之间使用的是tcp连接。 控制连接使用21端口&…...

经纬恒润高压电池管理系统,助力新能源汽车飞速发展

随着新能源汽车行业的快速发展&#xff0c;电池管理系统作为关键技术之一&#xff0c;其重要性日益凸显。经纬恒润自主研发的高压电池管理系统&#xff08;Battery Management System&#xff0c;BMS&#xff09;&#xff0c;凭借卓越的性能与先进的技术&#xff0c;在新能源汽…...

一文速通calcite结合flink理解SQL从文本变成执行计划详细过程

文章目录 你可以学到啥测试代码背景知识SQL转变流程图问题 你可以学到啥 SQL如何一步步变成执行计划的有哪些优化器&#xff0c;哪些优化规则calcite 和flink 如何结合的 测试代码 EnvironmentSettings settings EnvironmentSettings.inBatchMode(); TableEnvironment tabl…...

spring-TransactionTemplate 编程式事务

TransactionTemplate 是 Spring 框架提供的用于管理事务的一种方式。它提供了一种编程式的事务管理方法&#xff0c;允许开发者在代码中显式地控制事务的开始、提交或回滚。与使用 Transactional 注解相比&#xff0c;TransactionTemplate 提供了更多的灵活性和控制力。 为什么…...

中考全国45套(全国教育发达地区中考试卷)

文章目录 获取方式 为什么选择这份资源&#xff1f; 权威性与全面性&#xff1a;我们精心搜集了全国教育发达地区的最新中考试卷&#xff0c;确保每一套试卷都代表了该地区的教学水平和考试趋势。这不仅涵盖了丰富的知识点&#xff0c;还融入了各地独特的命题风格&#xff0c;让…...

嵌入式Linux学习笔记(5)-进程间常见通讯方式(c语言实现)

一、概述 进程间通信&#xff08;IPC&#xff0c;InterProcess Communication&#xff09;是指在多个进程之间进行数据传输和共享的机制。在操作系统中&#xff0c;进程是运行中的程序的实例&#xff0c;每个进程都有自己的内存空间和资源。 进程间通信可以用于在不同的进程之间…...

【移动端】菜单的自动展开与收回

前言 为了满足手机上菜单栏随用户移动&#xff0c;菜单的自动展示与隐藏&#xff0c;特此记录 基本原理 实现逻辑 window.addEventListener(‘scroll’, debouncedScrollHandler) – 监听文档视图滚动事件 document.querySelector(‘.header’) – 选择器匹配元素 创建show和h…...

Java获取Object中Value的方法

在Java中&#xff0c;获取对象&#xff08;Object&#xff09;中的值通常依赖于对象的类型以及我们希望访问的属性。由于Java是一种静态类型语言&#xff0c;直接从一个Object类型中访问属性是不可能的&#xff0c;因为Object是所有类的超类&#xff0c;但它本身不包含任何特定…...

集群聊天服务器项目【C++】(二)Json的简单使用

在上一章中&#xff0c;简单介绍了本项目的内容、技术栈、需求和目标等&#xff0c;详细介绍了环境配置&#xff0c;如果还没有配置成功&#xff0c;请参考我的上一篇博客环境配置 今天主要介绍Json库是什么以及简单的使用。 1.为什么要使用Json 我们在网络传输数据时&#…...

班迪录屏和这三款录屏工具,一键操作,太方便了!

嘿&#xff0c;小伙伴们&#xff01;今天我要跟大家分享几款超棒的录屏工具&#xff0c;它们绝对是我们在工作和学习中不可或缺的好帮&#xff1b;这些工具功能强大且操作简单&#xff0c;下面就让我来详细介绍一下它们的使用体验和好用之处吧&#xff01; 班迪录屏工具使用体…...

[特殊字符] 智能合约中的数据是如何在区块链中保持一致的?

&#x1f9e0; 智能合约中的数据是如何在区块链中保持一致的&#xff1f; 为什么所有区块链节点都能得出相同结果&#xff1f;合约调用这么复杂&#xff0c;状态真能保持一致吗&#xff1f;本篇带你从底层视角理解“状态一致性”的真相。 一、智能合约的数据存储在哪里&#xf…...

逻辑回归:给不确定性划界的分类大师

想象你是一名医生。面对患者的检查报告&#xff08;肿瘤大小、血液指标&#xff09;&#xff0c;你需要做出一个**决定性判断**&#xff1a;恶性还是良性&#xff1f;这种“非黑即白”的抉择&#xff0c;正是**逻辑回归&#xff08;Logistic Regression&#xff09;** 的战场&a…...

【磁盘】每天掌握一个Linux命令 - iostat

目录 【磁盘】每天掌握一个Linux命令 - iostat工具概述安装方式核心功能基础用法进阶操作实战案例面试题场景生产场景 注意事项 【磁盘】每天掌握一个Linux命令 - iostat 工具概述 iostat&#xff08;I/O Statistics&#xff09;是Linux系统下用于监视系统输入输出设备和CPU使…...

django filter 统计数量 按属性去重

在Django中&#xff0c;如果你想要根据某个属性对查询集进行去重并统计数量&#xff0c;你可以使用values()方法配合annotate()方法来实现。这里有两种常见的方法来完成这个需求&#xff1a; 方法1&#xff1a;使用annotate()和Count 假设你有一个模型Item&#xff0c;并且你想…...

376. Wiggle Subsequence

376. Wiggle Subsequence 代码 class Solution { public:int wiggleMaxLength(vector<int>& nums) {int n nums.size();int res 1;int prediff 0;int curdiff 0;for(int i 0;i < n-1;i){curdiff nums[i1] - nums[i];if( (prediff > 0 && curdif…...

微信小程序 - 手机震动

一、界面 <button type"primary" bindtap"shortVibrate">短震动</button> <button type"primary" bindtap"longVibrate">长震动</button> 二、js逻辑代码 注&#xff1a;文档 https://developers.weixin.qq…...

OkHttp 中实现断点续传 demo

在 OkHttp 中实现断点续传主要通过以下步骤完成&#xff0c;核心是利用 HTTP 协议的 Range 请求头指定下载范围&#xff1a; 实现原理 Range 请求头&#xff1a;向服务器请求文件的特定字节范围&#xff08;如 Range: bytes1024-&#xff09; 本地文件记录&#xff1a;保存已…...

2021-03-15 iview一些问题

1.iview 在使用tree组件时&#xff0c;发现没有set类的方法&#xff0c;只有get&#xff0c;那么要改变tree值&#xff0c;只能遍历treeData&#xff0c;递归修改treeData的checked&#xff0c;发现无法更改&#xff0c;原因在于check模式下&#xff0c;子元素的勾选状态跟父节…...

12.找到字符串中所有字母异位词

&#x1f9e0; 题目解析 题目描述&#xff1a; 给定两个字符串 s 和 p&#xff0c;找出 s 中所有 p 的字母异位词的起始索引。 返回的答案以数组形式表示。 字母异位词定义&#xff1a; 若两个字符串包含的字符种类和出现次数完全相同&#xff0c;顺序无所谓&#xff0c;则互为…...

C++八股 —— 单例模式

文章目录 1. 基本概念2. 设计要点3. 实现方式4. 详解懒汉模式 1. 基本概念 线程安全&#xff08;Thread Safety&#xff09; 线程安全是指在多线程环境下&#xff0c;某个函数、类或代码片段能够被多个线程同时调用时&#xff0c;仍能保证数据的一致性和逻辑的正确性&#xf…...