springmvc转为springboot--干货.docx
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
在网上找了很多springmvc转springboot的案例,大多都说的不全。 根据原springmvc项目(ssm+jsp)转换为springboot项目,爬了高很多坑,整理成此文档,希望对大家有所帮助。 将一个传统的Spring MVC项目迁移到Spring Boot的过程中,主要涉及到的核心技术包括Spring Boot的特性、SSM(Spring、Spring MVC、MyBatis)整合、Shiro安全框架、JSP视图解析以及Redis缓存等。以下是对这些关键点的详细解释: 1. **Spring Boot概述**: Spring Boot简化了Spring应用的初始搭建以及开发过程。它集成了大量常用的第三方库配置,如:Tomcat、JPA、Thymeleaf等,并提供了默认配置,使得开发者可以快速上手。 2. **Eclipse与STS插件**: Eclipse是一款广泛使用的Java IDE,而Spring Tools Suite (STS) 是Eclipse的一个插件,专门用于Spring应用的开发。安装STS插件后,可以方便地创建、管理和调试Spring Boot项目。 3. **转换步骤**: - **项目结构重构**:Spring Boot项目结构通常更为简洁,不再需要web.xml等配置文件。 - **依赖管理**:将原有的pom.xml或build.gradle文件中的依赖项更新为Spring Boot的起步依赖(Starter POMs)。 - **配置迁移**:将Spring MVC中的配置转移到Spring Boot的application.properties或application.yml文件中,例如服务器端口、数据源配置等。 - **Spring Boot启动器**:添加对应的Spring Boot启动器,如web、data-jpa、security等。 - **Shiro整合**:在Spring Boot中配置Shiro安全框架,处理用户认证和授权。 4. **配置文件**: - `application.properties`:配置文件中包含了服务器端口、环境选择、静态资源路径、模板引擎设置、数据源配置、连接池参数等。例如,关闭Thymeleaf缓存和启用,设置数据源连接信息等。 - `spring.profiles.active`:指定当前环境,如本地开发(local)、测试(test)、生产(production)。 5. **资源路径**: Spring Boot允许定义静态资源的路径,如CSS、JS、图片等。在本例中,静态资源位于多个类路径下,例如`/static`, `/admin`, `/data`, `/plugins`, `/uploadFiles`, 和 `/META-INF/resources`。 6. **MyBatis配置**: MyBatis的配置包括mapper文件的位置、类型别名包以及全局配置文件。在Spring Boot中,可以通过`mybatis.mapper-locations`, `mybatis.type-aliases-package`, 和 `mybatis.config-location`来指定。 7. **JSP视图解析**: 在Spring Boot中,通过配置`spring.mvc.view.prefix`和`spring.mvc.view.suffix`来指定JSP视图的前缀和后缀。注意,由于Spring Boot默认不支持JSP,因此需要额外配置,如引入Tomcat的JSP支持。 8. **Redis缓存**: 如果原项目中使用了Redis作为缓存,需要在Spring Boot中配置Redis的相关属性,如连接信息、数据库索引等。 9. **监控与日志**: Spring Boot提供了Actuator组件用于健康检查、性能监控等。配置监控统计拦截的filters,如`stat,wall,log4j`,以便收集应用运行时的详细信息。 10. **测试与调整**: 转换完成后,进行单元测试和集成测试,确保所有功能正常运行。可能需要调整的配置包括连接池参数、超时时间、资源加载路径等,以优化应用性能。 这个过程涉及到的技术广泛,每个环节都需要仔细处理,确保原有功能在Spring Boot环境中正常工作。通过以上步骤,可以成功将一个基于Spring MVC的项目转换为Spring Boot项目,享受其自动化配置和便捷性带来的开发效率提升。
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/release/download_crawler_static/11503936/bg1.jpg)
![](https://csdnimg.cn/release/download_crawler_static/11503936/bg2.jpg)
剩余7页未读,继续阅读
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- zysjsj2022-06-27无用资源,去网页复制的贴成word格式都不调一下。
- visionshao2020-07-17还可以参考参考
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 1
- 资源: 6
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)