首页 > 其他分享 >Springboot版本升级

Springboot版本升级

时间:2024-04-25 21:14:34浏览次数:11  
标签:Springboot -- boot Length 版本升级 import org springfox

升级简介

开发软件:IDEA2019
项目环境:java 8,springboot2.0.5
目标版本:java 8,springboot2.5.5

本文档前后变化对比,旧代码使用、// 等表示。

依赖升级

升级版本

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<!-- <version>2.0.5.RELEASE</version>  -->
		<version>2.5.5</version> <!-- lookup parent from repository -->
	</parent>

<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<!-- <spring-cloud.version>Finchley.RELEASE</spring-cloud.version> -->
		<spring-cloud.version>2020.0.3</spring-cloud.version>
		<skipTests>true</skipTests>
		<easypoi.version>3.2.0</easypoi.version>
		<!-- <tomcat.version>8.5.81</tomcat.version> -->
		<tomcat.version>9.0.50</tomcat.version>
</properties>

      <dependency>
			<groupId>io.netty</groupId>
			<artifactId>netty-all</artifactId>
		<!-- 	<version>4.1.28.Final</version> -->
			<version>4.1.6.Final</version>
		</dependency>

      <dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-spring-boot-web-starter</artifactId>
			<!-- <version>1.4.0</version> -->
			<version>1.7.1</version>
		</dependency>

新增

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>
		<!-- Swagger 2 -->
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger2</artifactId>
			<version>2.9.2</version>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>2.9.2</version>
		</dependency>

代码调整

import变化

import org.apache.commons.lang.StringUtils;
改为
import org.apache.commons.lang3.StringUtils;

CollectionUtils变化

        set.addAll(CollectionUtils.arrayToList(str.split(",")));
//        set.addAll(CollectionUtils.arrayToList(str.split(",")));//2.0.5

验证变化

Length变为Size

//import org.hibernate.validator.constraints.Length;
import org.checkerframework.checker.units.qual.Length;

注解修改

    //@Length(min = 1, max = 100, message = "发送对象不能为空")
    @Size(min = 1, max = 100, message = "发送对象不能为空")

Shiro

提示ShiroFilterFactoryBean不存在

 //@Bean
    @Bean(name = "shiroFilterFactoryBean")
    public ShiroFilterFactoryBean factory(SecurityManager securityManager) {

跨域问题

使用addAllowedOrigin导致跨域不成功,提示不允许使用*

//        corsConfiguration.addAllowedOrigin("*");
        //原本是addAllowedOrigin,改为addAllowedOriginPattern
        corsConfiguration.addAllowedOriginPattern("*");

增加启动配置

  @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**").allowCredentials(true).allowedOriginPatterns("*");
            }
        };
    }

标签:Springboot,--,boot,Length,版本升级,import,org,springfox
From: https://www.cnblogs.com/xcsn/p/18158589

相关文章

  • springboot的日志swagger的配置
    我们导入swagger分为三步一.导入依赖首先我们需要在项目的pom里导入依赖<dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-spring-boot-starter</artifactId><version>3.0......
  • 利用SpringBoot的CommandLineRunner编写命令行jar程序
    1.项目pom<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.......
  • springboot中使用spring-javaformat-maven-plugin格式化代码插件
    在springboot项目中,想通过使用插件来统一项目中的代码,我这里选用的是spring-javaformat-maven-plugin。maven项目中,使用步骤如下:一、导入插件依赖pom.xml中添加<build><plugins><!--格式化代码插件--><plugin><groupId>i......
  • springboot+mybatisplus+dynicDatasource 从数据库表中查询数据源 动态添加
    1、pom依赖<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.12</version><relativePath/><!--lookuppa......
  • springboot mybatis-plus dynamic-datasource实现
    基础架构是springboot+mybatis-plus实现动态数据源步骤步骤1:pom文件<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.7.12</version>......
  • SpringBoot项目添加2FA双因素身份认证
    什么是2FA(双因素身份验证)?双因素身份验证(2FA)是一种安全系统,要求用户提供两种不同的身份验证方式才能访问某个系统或服务。国内普遍做短信验证码这种的用的比较少,不过在国外的网站中使用双因素身份验证的还是很多的。用户通过使用验证器扫描二维码,就能在app上获取登录的动态口令,......
  • SpringBoot项目实现日志打印SQL明细(包括SQL语句和参数)几种方式
    前言我们在开发项目的时候,都会连接数据库。有时候遇到问题需要根据我们编写的SQL进行分析,但如果不进行一些开发或者配置的话,这些SQL是不会打印到控制台的,它们默认是隐藏的。下面给大家介绍几种常用的方法。第一种、代码形式Mybatis框架是Java程序员最常用的数据库映射框架,MyBa......
  • gcc版本升级
     升级链接:CentOS7gcc版本需升级到7.5.0,详细可参考文档:https://learn.microsoft.com/zh-cn/azure/cognitive-services/speech-service/how-to-configure-rhel-centos-7 按照上面的操作完成后,还是不行,语音转换接口访问还是报错。按照如下步骤,将库文件改掉,将旧的包卸载,然后......
  • 9.prometheus监控--监控springboot2.x(Java)
    一、环境部署yumsearchjava|grepjdkyuminstall-yjava-11-openjdk-devel二、监控java应用(tomcat/jar)JMXexporter负责收集Java虚拟机信息---没举例,等以后再做测试进入到tomcat安装目录,vimPROMETHEUS_JMX_EXPORTER_OPTS="-javaagent:../prometheus-exporter......
  • springboot的netty代码实操
    参考:https://www.cnblogs.com/mc-74120/p/13622008.htmlpom文件<dependency><groupId>io.netty</groupId><artifactId>netty-all</artifactId></dependency>启动类@EnableFeignClients@EnableDiscoveryClient@EnableSchedu......