Maven 创建 Spring、SpringMVC、Mybatis(SSM)项目
创建maven SSM项目包名、目录POM文件?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd modelVersion4.0.0/modelVersion groupIdcom.qiuhen.m.ssm/groupId artifactIdmake/artifactId version1.0-SNAPSHOT/version packagingwar/packaging namemake Maven Webapp/name properties project.build.sourceEncodingUTF-8/project.build.sourceEncoding maven.compiler.source1.8/maven.compiler.source maven.compiler.target1.8/maven.compiler.target spring.version4.3.13.RELEASE/spring.version /properties dependencies !--Spring-- dependency groupIdorg.springframework/groupId artifactIdspring-core/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-aop/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-orm/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-web/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-webmvc/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-tx/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-test/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-jdbc/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-mock/artifactId version2.0.8/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-context/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-expression/artifactId version4.3.5.RELEASE/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-context-support/artifactId version4.3.5.RELEASE/version /dependency !-- mybatis-spring -- dependency groupIdorg.mybatis/groupId artifactIdmybatis-spring/artifactId version1.3.1/version /dependency !-- mybatis 出现分页使用异常,极有可能是版本问题-- dependency groupIdorg.mybatis/groupId artifactIdmybatis/artifactId version3.2.8/version /dependency !-- mybatis pagehelper -- dependency groupIdcom.github.pagehelper/groupId artifactIdpagehelper/artifactId version3.7.3/version /dependency dependency groupIdcom.github.jsqlparser/groupId artifactIdjsqlparser/artifactId version0.9.1/version /dependency !--servlet、基本包-- dependency groupIdjavax.servlet/groupId artifactIdservlet-api/artifactId version3.0-alpha-1/version /dependency dependency groupIdjavax.servlet/groupId artifactIdjstl/artifactId version1.2/version /dependency dependency groupIdtaglibs/groupId artifactIdstandard/artifactId version1.1.2/version /dependency dependency groupIdorg.aspectj/groupId artifactIdaspectjrt/artifactId version1.8.10/version /dependency dependency groupIdorg.aspectj/groupId artifactIdaspectjweaver/artifactId version1.8.10/version /dependency dependency groupIdcommons-lang/groupId artifactIdcommons-lang/artifactId version2.6/version /dependency dependency groupIddom4j/groupId artifactIddom4j/artifactId version1.6.1/version /dependency !--mysql驱动包-- dependency groupIdmysql/groupId artifactIdmysql-connector-java/artifactId version5.1.40/version /dependency !--dbcp连接池-- dependency groupIdcommons-dbcp/groupId artifactIdcommons-dbcp/artifactId version1.4/version /dependency !--json、基本包-- dependency groupIdcom.alibaba/groupId artifactIdfastjson/artifactId version1.2.23/version /dependency dependency groupIdxml-apis/groupId artifactIdxml-apis/artifactId version2.0.2/version /dependency dependency groupIdcommons-net/groupId artifactIdcommons-net/artifactId version3.5/version /dependency !-- 日志文件管理包 -- dependency groupIdorg.slf4j/groupId artifactIdslf4j-api/artifactId version1.7.22/version /dependency dependency groupIdorg.slf4j/groupId artifactIdslf4j-log4j12/artifactId version1.7.22/version /dependency dependency groupIdlog4j/groupId artifactIdlog4j/artifactId version1.2.17/version /dependency !-- junit4 -- dependency groupIdjunit/groupId artifactIdjunit/artifactId version4.12/version scopetest/scope /dependency !-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -- dependency groupIdcommons-fileupload/groupId artifactIdcommons-fileupload/artifactId version1.4/version /dependency /dependencies build finalNamemake/finalName pluginManagement!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -- plugins plugin artifactIdmaven-clean-plugin/artifactId version3.1.0/version /plugin !-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -- plugin artifactIdmaven-resources-plugin/artifactId version3.0.2/version /plugin plugin artifactIdmaven-compiler-plugin/artifactId version3.8.0/version /plugin plugin artifactIdmaven-surefire-plugin/artifactId version2.22.1/version /plugin plugin artifactIdmaven-war-plugin/artifactId version3.2.2/version /plugin plugin artifactIdmaven-install-plugin/artifactId version2.5.2/version /plugin plugin artifactIdmaven-deploy-plugin/artifactId version2.8.2/version /plugin /plugins /pluginManagement /build /project引入spring、mybatis、mysql等相关jar包Web.xml的相关配置?xml version1.0 encodingUTF-8? web-app xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlnshttp://java.sun.com/xml/ns/javaee xsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd idWebApp_ID version3.0 display-nameSpringMVC/display-name welcome-file-list welcome-file/WEB-INF/index.jsp/welcome-file /welcome-file-list !-- 加载log4j -- context-param param-namelog4jConfigLocation/param-name param-valueclasspath:config/log4j.properties/param-value /context-param listener listener-classorg.springframework.web.util.Log4jConfigListener/listener-class /listener !-- 配置请求转发、拦截器 -- servlet servlet-namespringmvc/servlet-name servlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class !-- 初始化springmvc的配置文件 -- init-param param-namecontextConfigLocation/param-name param-valueclasspath:spring/springmvc.xml/param-value /init-param /servlet servlet-mapping servlet-namespringmvc/servlet-name !-- 配置拦截规则 -- url-pattern*.action/url-pattern !--后缀名自起常用.do\.action-- /servlet-mapping !-- 配置spring监听器项目启动加载spring的配置 -- context-param param-namecontextConfigLocation/param-name param-valueclasspath:spring/applicationContext.xml/param-value /context-param listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener filter filter-nameencoding/filter-name filter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueUTF-8/param-value /init-param /filter filter-mapping filter-nameencoding/filter-name url-pattern*.action/url-pattern /filter-mapping /web-appapplicationContext配置文件springs的核心配置?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:contexthttp://www.springframework.org/schema/context xmlns:aophttp://www.springframework.org/schema/aop xmlns:txhttp://www.springframework.org/schema/tx xsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd !-- 加载数据库配置文件的信息 -- context:property-placeholder locationclasspath:config/db.properties/ !-- 配置DBCP连接池 -- bean iddataSource classorg.apache.commons.dbcp.BasicDataSource destroy-methodclose property namedriverClassName value${jdbc.driver} / property nameurl value${jdbc.url} / property nameusername value${jdbc.username} / property namepassword value${jdbc.password} / property namemaxActive value10 / property namemaxIdle value5 / /bean !-- Mybatis工厂配置配置SqlSessionFactory -- bean idsqlSessionFactory classorg.mybatis.spring.SqlSessionFactoryBean !-- 加载mybatis的核心配置文件 -- property nameconfigLocation valueclasspath:spring/mybatis.xml/property !-- 配置数据源 -- property namedataSource refdataSource/property /bean !-- Mapper动态代理开发扫描包的形式 -- bean classorg.mybatis.spring.mapper.MapperScannerConfigurer !-- 指定扫描的包 -- property namebasePackage valuecn.qiuhen.dao/property /bean /beansSpring MVC的核心配置springmvc.xml?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:contexthttp://www.springframework.org/schema/context xmlns:aophttp://www.springframework.org/schema/aop xmlns:txhttp://www.springframework.org/schema/tx xmlns:mvchttp://www.springframework.org/schema/mvc xsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd !-- 配置Controller扫描包相当于Struts2中的Action,将哪些类交给spring管理 -- context:component-scan base-packagecn.qiuhen.controller/context:component-scan !-- 启动注解驱动自动装配controller、service、dao -- mvc:annotation-driven/mvc:annotation-driven !-- 扫描controller,servicecontroller,service层注入 -- context:component-scan base-packagecn.qiuhen.controller/ context:component-scan base-packagecn.qiuhen.service/ !-- 配置视图处理器 -- bean classorg.springframework.web.servlet.view.InternalResourceViewResolver !-- 配置逻辑试图的前缀 -- property nameprefix value/WEB-INF/jsp//property !-- 配置逻辑试图的后缀 -- property namesuffix value.jsp/property /bean !-- 启用注解驱动自动装配controller、service、dao -- mvc:annotation-driven conversion-servicecustomConverter/ !-- 自定义参数类型转换 -- bean idcustomConverter classorg.springframework.format.support.FormattingConversionServiceFactoryBean !-- 定义转换器可以有很多转换器 -- property nameconverters list !-- 可以加载很多自定义的类型转换器 -- bean classcn.qiuhen.conversion.String2DateConverter/bean /list /property /bean !--文件上传-- bean idmultipartResolver classorg.springframework.web.multipart.commons.CommonsMultipartResolver !-- 设定文件上传的最大值为5MB5*1024*1024 -- property namemaxUploadSize value5242880/property !-- 设定文件上传时写入内存的最大值如果小于这个参数不会生成临时文件默认为10240 -- property namemaxInMemorySize value40960/property !-- 上传文件的临时路径 -- property nameuploadTempDir valuefileUpload/temp/property !-- 延迟文件解析 -- property nameresolveLazily valuetrue/ /bean /beansMybatis配置Mybatis.xml?xml version1.0 encodingUTF-8? !DOCTYPE configuration PUBLIC -//mybatis.org//DTD Config 3.0//EN http://mybatis.org/dtd/mybatis-3-config.dtd configuration !-- 类型别名 typeAliases必须配置文件的开始部分 -- typeAliases !-- 可以指定一个包名mybatis会在包名下面搜索需要的javaBean -- package namecn.qiuhen.domain/ /typeAliases !-- 加载映射文件 -- mappers !-- package namecn.qiuhen.dao/-- mapper resourcemybatis/BookMapper.xml/mapper /mappers /configuration数据库db.properties配置#MySQL jdbc.drivercom.mysql.jdbc.Driver jdbc.urljdbc:mysql://localhost:3306/nutzwk?useUnicodetruecharacterEncodingUTF-8 jdbc.usernameroot jdbc.passwordroot #SQLServer #drivercom.microsoft.sqlserver.jdbc.SQLServerDriver #urljdbc\:sqlserver\://localhost\:1433;DatabaseName\test #usernameautek #passwordflyvideoLog4j配置注意必须要配置不然无法打印日志信息和错误信息Log4j.properties(只是简单配置根据自己需求修改)# Global logging configuration log4j.rootLoggerDEBUG, stdout # Console output... log4j.appender.stdoutorg.apache.log4j.ConsoleAppender log4j.appender.stdout.layoutorg.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern%5p [%t] - %m%nPojo(示例)Controller(示例)Service层示例为求简洁没创建接口只是一个类dao层示例dao配置文件Jsp页面仅供参考% page contentTypetext/html;charsetUTF-8 languagejava % % taglib urihttp://java.sun.com/jsp/jstl/core prefixc % !--输出,条件,迭代标签库-- %--% page isELIgnoredfalse% !--支持EL表达式不设的话EL表达式不会解析-- --% % String path request.getContextPath(); String basePath request.getScheme() :// request.getServerName() : request.getServerPort() path /; % html head title第一页/title link relstylesheet href${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css link relstylesheet href${pageContext.request.contextPath}/static/datepicker/bootstrap-datetimepicker.min.css /head script src${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js/script script src${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.js/script script src${pageContext.request.contextPath}/static/datepicker/bootstrap-datetimepicker.min.js/script script src${pageContext.request.contextPath}/static/js/bootstrap-datetimepicker.zh-CN.js/script script src${pageContext.request.contextPath}/static/kindeditor/kindeditor-all.js/script script src${pageContext.request.contextPath}/static/kindeditor/lang/zh_CN.js/script script src${pageContext.request.contextPath}/static/kindeditor/plugins/code/prettify.js /script script KindEditor.ready(function (K) { var editor1 K.create(textarea[namearticle.content1], { cssPath: ${pageContext.request.contextPath}/static/kindeditor/plugins/code/prettify.css, uploadJson: ${pageContext.request.contextPath}/static/kindeditor/jsp/upload_json.jsp, fileManagerJson: ${pageContext.request.contextPath}/static/kindeditor/jsp/file_manager_json.jsp, allowFileManager: true, afterCreate: function () { var self this; K.ctrl(document, 13, function () { self.sync(); document.forms[example].submit(); }); K.ctrl(self.edit.doc, 13, function () { self.sync(); document.forms[example].submit(); }); } }); prettyPrint(); }); /script body %--页面跳转与请求--% div stylewidth:300px;height:150px;border: 1px solid black; %--点击按照发送ajax请求--% button idbtn按钮/button %--点击跳转页面--% a classbtn btn-primary href%basePath%home/index.actiondsa/a /div div stylewidth:800px;height:150px;border: 1px solid black; p日期插件/p div classform-group label forat classcol-sm-2 control-label发布时间/label div classcol-sm-8 input-group date form_datetime stylepadding-left: 16px;padding-right: 16px; >

相关新闻

领优惠券APP数据中台建设:GMV、佣金与用户留存率的实时数据监控体系

领优惠券APP数据中台建设:GMV、佣金与用户留存率的实时数据监控体系

领优惠券APP数据中台建设:GMV、佣金与用户留存率的实时数据监控体系 大家好,我是省赚客APP研发者微赚淘客! 在导购返利行业,数据是驱动业务增长的核心引擎。GMV(商品交易总额)、预估佣金和用户留存率是衡…

2026/7/28 16:21:44阅读更多 →
Python replace函数

Python replace函数

replace函数 字符串处理函数 语法:str.replace(old,new[,max]) old需要进行更换的旧子串new新的子串,将取代旧的子字符串(子串可以为空)max如果可选参数max值给出,表示出现前max的次数的子串被替换 str"monkey li…

2026/7/28 16:19:44阅读更多 →
基于二代和三代测序技术的柚子基因组混合拼装

基于二代和三代测序技术的柚子基因组混合拼装

第二代 和第三代测序技术的出现推动了基因组项目 和高通量基因组学 研究的快速发展1.3 第二代 和第三代高通量测序技术及其特点除了少数物种以RNA或多肽 作为 遗传信息的载体之外,绝大多数生物以 DNA分子作为自身的遗传物质。利用DNA测序技术获得DNA的碱基序列信息并对其进行解…

2026/7/28 16:19:44阅读更多 →
多款数字人产品从文案到成片流程实测

多款数字人产品从文案到成片流程实测

2026年7月实测:从文案到成片,6款AI数字人产品全流程自动化能力深度测评本文适用于正在寻找短视频内容规模化生产方案的企业管理者、新媒体运营负责人、知识付费创作者以及本地生活服务商。核心结论前置:当前市面上的AI数字人工具在形象克隆与…

2026/7/28 18:40:09阅读更多 →
POJ - 1321 棋盘问题 (DFS递归)

POJ - 1321 棋盘问题 (DFS递归)

在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入…

2026/7/28 18:40:09阅读更多 →
VMware设置共享文件夹之后Ubuntu中看不到怎么办?

VMware设置共享文件夹之后Ubuntu中看不到怎么办?

一、共享文件夹设置好了,但是在虚拟机中的Ubuntu系统下却看不到,怎么办? 一种可能的原因是系统没有自动挂载,解决办法: 1、安装: sudo apt-get install open-vm-dkms 2、挂…

2026/7/28 18:40:09阅读更多 →
云计算安全

云计算安全

云计算的安全威胁数据泄露、数据丢失、流量劫持大流量DDoS攻击、SQL注入攻击、暴力破解攻击、木马、XSS攻击、网络钓鱼攻击审计不到位、内部员工越权、滥用权力、操作失误等云服务中断、滥用云服务、多租户隔离失败安全责任界定不清不安全的接口其他不同层次的安全威胁网络层次…

2026/7/28 18:40:09阅读更多 →
昆仑大模型企业级AI部署实战指南

昆仑大模型企业级AI部署实战指南

1. 昆仑大模型到底是什么?能解决什么问题?昆仑大模型不是通用聊天机器人,而是面向企业级场景的AI基础设施。从公开资料看,它最核心的价值是三个:全模态支持:同时覆盖文本(3000亿参数语言模型&am…

2026/7/28 18:40:09阅读更多 →
Shell - 常用命令

Shell - 常用命令

l 列出当前行上下各5行,总共10行 q|quit 退出 h 帮助 /for/ 向后搜索字符串for ?for? 向前搜索字符串for x 12 计算算术表达式的值 !! ls -laRt 执行shell命令 n 执行下一条语句 s 4 …

2026/7/28 18:38:09阅读更多 →
覆盖国产 + 海外 + 开源模型,OpenClaw 2.7.9 Windows/Mac 双端部署详解

覆盖国产 + 海外 + 开源模型,OpenClaw 2.7.9 Windows/Mac 双端部署详解

🔹 工具基础介绍 OpenClaw 是开源生态中一款实用性较强的本地智能工具,凭借本地离线运行、可视化图形操作和任务自动化三大核心特性,赢得了众多用户的青睐。与普通在线对话AI工具不同,它属于能够直接操控本机软硬件的智能数字员工…

2026/7/28 4:06:39阅读更多 →
伺服阀焊完微漏毁整机?精密激光焊接三关锁住高压

伺服阀焊完微漏毁整机?精密激光焊接三关锁住高压

所谓液压伺服阀体的精密激光焊接,是用激光束对阀座壳体(通常为不锈钢或铝合金)进行密封焊接,使阀体在21-35MPa的高压液压油或压缩气体中长期运行而不发生介质泄漏。液压伺服阀是高端液压系统的"大脑"。从航空航天飞行控…

2026/7/28 2:08:06阅读更多 →
D2DX:三步实现《暗黑破坏神2》高清宽屏体验的终极指南

D2DX:三步实现《暗黑破坏神2》高清宽屏体验的终极指南

D2DX:三步实现《暗黑破坏神2》高清宽屏体验的终极指南 【免费下载链接】d2dx D2DX is a complete solution to make Diablo II run well on modern PCs, with high fps and better resolutions. 项目地址: https://gitcode.com/gh_mirrors/d2/d2dx 你是否还在…

2026/7/28 1:38:28阅读更多 →
告别臃肿!3步让你的暗影精灵笔记本重获新生

告别臃肿!3步让你的暗影精灵笔记本重获新生

告别臃肿!3步让你的暗影精灵笔记本重获新生 【免费下载链接】OmenSuperHub Control Omen laptop performance, fan speeds, and keyboard lighting, and unlock power limits. 项目地址: https://gitcode.com/gh_mirrors/om/OmenSuperHub 你是否也曾为官方Om…

2026/7/28 0:00:29阅读更多 →
RAG必踩坑!财报法规检索不准?这款开源工具让答案浮出水面,准确率飙升98.7%!

RAG必踩坑!财报法规检索不准?这款开源工具让答案浮出水面,准确率飙升98.7%!

做 RAG 的人应该都踩过这个致命的坑:把几百页的财报、法规、技术手册扔给向量库,问一个具体问题,搜出来的全是沾边但没用的内容 —— 关键信息要么被硬切块拆碎了,要么藏在几十条结果的最下面。语义相似≠真正相关,这个…

2026/7/28 0:00:29阅读更多 →
抖音视频文案提取工具全指南:免费2026版、手机App、在线工具一网打尽

抖音视频文案提取工具全指南:免费2026版、手机App、在线工具一网打尽

2026年做短视频运营,从抖音上扒文案早就不是偷偷抄笔记的事了。我刚开始做内容的时候,每天刷半小时抖音,手动把爆款视频的口播敲进备忘录,一条2分钟的视频得花十来分钟,碰到语速快的还要反复回听。后来试了一圈工具&am…

2026/7/28 0:00:29阅读更多 →
YOLOv8推理性能优化:从1.2FPS到35FPS的全链路加速实践

YOLOv8推理性能优化:从1.2FPS到35FPS的全链路加速实践

如果你在部署 YOLOv8 时,发现推理速度只有可怜的 1-2 FPS,而别人的演示视频却能跑到 30 FPS 以上,那么问题很可能不在模型本身,而在于你的整个处理链路。很多开发者拿到一个训练好的 YOLOv8 模型后,会直接使用官方示例…

2026/7/27 16:57:54阅读更多 →
Coze与Dify对比指南:低代码AI应用开发从入门到实战

Coze与Dify对比指南:低代码AI应用开发从入门到实战

1. 从零到一:为什么你需要了解 Coze 和 Dify?如果你对 AI 应用开发感兴趣,但一看到“大模型”、“智能体”、“工作流”这些词就头疼,觉得门槛太高,那这篇文章就是为你准备的。很多开发者,包括我自己&#…

2026/7/28 3:17:03阅读更多 →
AI生图工具怎么选?2026年6月版实测对比

AI生图工具怎么选?2026年6月版实测对比

做自媒体的朋友应该都有体会:配图一直是个让人头疼的问题。2026年,AI生图工具已经非常成熟了,但工具太多反而不知道怎么选。以下是截至2026年6月我对主流AI生图工具的实测对比。Midjourney V8.1:速度之王2026年6月11日&#xff0c…

2026/7/28 2:35:58阅读更多 →