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

网络推广网站建设有限公司东莞seo计费管理

网络推广网站建设有限公司,东莞seo计费管理,服装网站建设论文,python做网站部署springboot2.x升级springboot3.x 背景升级jdk版本为17以上springboot版本修改javax包更新mybatis-plus升级swagger升级springdocspringdoc配置 背景 当前项目是springboot2.5.9版本的springbootmybatis-plus项目,需要升级到springboot3.5.0项目。 升级jdk版本为17…

springboot2.x升级springboot3.x

  • 背景
    • 升级jdk版本为17以上
    • springboot版本修改
    • javax包更新
    • mybatis-plus升级
    • swagger升级springdoc
    • springdoc配置

背景

当前项目是springboot2.5.9版本的springboot+mybatis-plus项目,需要升级到springboot3.5.0项目。

升级jdk版本为17以上

Spring Boot 3.x 需 ​Java 17+​,检查并升级 JDK:

<properties><java.version>17</java.version>
</properties>

springboot版本修改

修改 pom.xml 中的父依赖版本:

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.9</version><relativePath/> <!-- lookup parent from repository --></parent>

升级版本

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.5.0</version><relativePath/> <!-- lookup parent from repository --></parent>

javax包更新

全局替换 javax.* 为 jakarta.*(涉及 Servlet、JPA 等):

// 旧:import javax.servlet.HttpServletRequest;
// 新:import jakarta.servlet.HttpServletRequest;

在这里插入图片描述

mybatis-plus升级

 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId><version>3.5.12</version></dependency><!--mybatis-plus分页插件使用必须依赖项--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-jsqlparser</artifactId><version>3.5.12</version></dependency>

这里面分页需要注意,必须引入新的依赖。

swagger升级springdoc

Spring 社区已明确推荐使用 ​springdoc-openapi​ 替代 springfox,因其原生支持 Jakarta EE 并与 Spring Boot 3.x 完全兼容

老版本的swagger

<dependency><groupId>io.springfox</groupId><artifactId>springfox-boot-starter</artifactId><version>3.0.0</version></dependency>

替换为新的swagger

 <dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId><version>2.8.8</version></dependency>

springdoc配置

调整路径匹配策略

Spring Boot 3.x 默认使用 PathPatternParser,但 Swagger UI 需切换为传统 AntPathMatcher:
application.yml

spring:mvc:pathmatch:matching-strategy: ant_path_matcher

删除swaggerconfig配置类

新增springdoc配置类


@Configuration
@SecurityScheme(name = "Bearer Authentication",type = SecuritySchemeType.HTTP,bearerFormat = "JWT",scheme = "bearer"
)
public class SpringDocConfig {@Beanpublic OpenAPI customOpenApi() {return new OpenAPI().info(new Info().title("xxxAPI 文档").description("这是一个xxx系统的API文档。").version("1.0").contact(new Contact().name("开发团队").email("support@example.com").url("https://github.com/")).license(new License().name("MIT License").url("https://opensource.org/licenses/MIT")).termsOfService("http://example.com/terms/")).externalDocs(new ExternalDocumentation().description("更多文档").url("http://example.com/docs")).addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"));}@Beanpublic GroupedOpenApi allApi() {return GroupedOpenApi.builder().group("所有接口").pathsToMatch("/**").packagesToScan("com.xxx.xxx.controller").build();}

spring-doc配置

springdoc:api-docs:enabled: truepath: /v3/api-docsswagger-ui:path: /swagger-ui.htmlurl: /v3/api-docsdisable-swagger-default-url: falsetags-sorter: alphaoperations-sorter: alphapackages-to-scan: com.xxx.controllerpaths-to-match: /**show-actuator: falsedefault-produces-media-type: application/jsondefault-consumes-media-type: application/json

其他修改:

依次将swagger的注解更改为springdoc的注解
主要使用springdoc的@Schema注解对类和属性进行标注:@Schema(description = "xxx对象")
http://www.dtcms.com/wzjs/467388.html

相关文章:

  • 如何建网站商城网店运营策划方案
  • wordpress 入侵视频教程苏州seo整站优化
  • 沈阳医疗网站制作网络广告策划方案范文
  • 让你有做黑客感觉的网站广州网站优化
  • 建立网站的作用东莞seo快速排名
  • 发布的手机网站是乱码营销管理制度范本
  • 武汉做网站的公司哪家好seo网站的优化方案
  • 淘宝客做自己网站app推广渠道在哪接的单子
  • 正规的网站建设学习网暴疯团队seo课程
  • 那个免费做微信订阅号的网站口碑营销有哪些
  • 爱心互助网站开发google下载官方版
  • 建设企业网站收款人为其他行打不开傻瓜式自助建站系统
  • 做ppt设计师哪个网站好企业网站seo诊断工具
  • 马化腾做的电商网站乔拓云建站平台
  • 网站上的在线答题是怎么做的建网站教学
  • 无锡微信网站建设价格电商运营推广的方式和渠道有哪些
  • 杭州企业网站设计搜素引擎优化
  • 一键抓取的网站怎么做百度推广费用一天多少钱
  • 建网站需要软件深圳seo网络推广
  • wordpress怎么建一个文章链接页面北京seo网络推广
  • 怎么把wordpress字去掉郑州seo方案
  • 佛山做网站公司重庆网站推广软件
  • 做网站推广有什么升职空间seo石家庄
  • 社群电商平台排名南宁百度首页优化
  • 金阊做网站价格今日头条新闻大事件
  • 施工企业费用预算的编制的内容包括哪些什么是搜索引擎优化?
  • 订阅号做影视网站百度的首页
  • 怎样在局域网做网站网络营销方案策划论文
  • 小企业做网站有用吗公司网站制作流程
  • seo网站收录工具孔宇seo