Spring Framework版本升级

Spring Framework版本升级

升级Spring Framework 版本

由于公司漏洞扫描后要求项目中Spring Framework版本不低于5.3.18,通过idea插件maven helper,查看所有项目中Spring Framework的版本,发现5个项目中的版本低于5.3.18,需要进行版本升级
1. springboot项目

​ 对于springboot项目,查看springboot版本和他依赖的Spring Framework的对应关系(从这个网址查询,修改地址中的2.6.6为你要查询的版本号)

springboot版本 依赖springframework版本 发布时间
1.0.x
1.0.0.RELEASE 4.0.3.RELEASE 2014.04
1.0.1.RELEASE 4.0.3.RELEASE 2014.04
1.0.2.RELEASE 4.0.3.RELEASE 2014.04
1.1.x
1.1.0.RELEASE 4.0.5.RELEASE 2014.06
1.1.1.RELEASE 4.0.5.RELEASE 2014.06
1.1.2.RELEASE 4.0.5.RELEASE 2014.06
1.1.3.RELEASE 4.0.5.RELEASE 2014.06
1.1.4.RELEASE 4.0.6.RELEASE 2014.07
1.1.5.RELEASE 4.0.6.RELEASE 2014.08
1.1.6.RELEASE 4.0.6.RELEASE 2014.09
1.1.7.RELEASE 4.0.7.RELEASE 2014.09
1.1.8.RELEASE 4.0.7.RELEASE 2014.10
1.1.9.RELEASE 4.0.8.RELEASE 2014.11
1.1.10.RELEASE 4.0.8.RELEASE 2014.12
1.1.11.RELEASE 4.0.9.RELEASE 2015.02
1.1.12.RELEASE 4.0.9.RELEASE 2015.03
1.2.x
1.2.0.RELEASE 4.1.3.RELEASE 2014.12
1.2.1.RELEASE 4.1.4.RELEASE 2015.01
1.2.2.RELEASE 4.1.5.RELEASE 2015.02
1.2.3.RELEASE 4.1.6.RELEASE 2015.03
1.2.4.RELEASE 4.1.6.RELEASE 2015.06
1.2.5.RELEASE 4.1.7.RELEASE 2015.07
1.2.6.RELEASE 4.1.8.RELEASE 2015.09
1.2.7.RELEASE 4.1.3.RELEASE 2015.10
1.2.8.RELEASE 4.1.9.RELEASE 2015.12
1.3.x
1.3.0.RELEASE 4.2.3.RELEASE 2015.11
1.3.1.RELEASE 4.2.4.RELEASE 2015.12
1.3.2.RELEASE 4.2.4.RELEASE 2016.01
1.3.3.RELEASE 4.2.5.RELEASE 2016.02
1.3.4.RELEASE 4.2.6.RELEASE 2016.05
1.3.5.RELEASE 4.2.6.RELEASE 2016.05
1.3.6.RELEASE 4.2.7.RELEASE 2016.06
1.3.7.RELEASE 4.2.7.RELEASE 2016.06
1.3.8.RELEASE 4.2.8.RELEASE 2016.09
1.4.x
1.4.0.RELEASE 4.3.2.RELEASE 2016.07
1.4.1.RELEASE 4.3.3.RELEASE 2016.09
1.4.2.RELEASE 4.3.4.RELEASE 2016.11
1.4.3.RELEASE 4.3.5.RELEASE 2016.12
1.4.4.RELEASE 4.3.6.RELEASE 2017.01
1.4.5.RELEASE 4.3.7.RELEASE 2017.03
1.4.6.RELEASE 4.3.8.RELEASE 2017.04
1.4.7.RELEASE 4.3.9.RELEASE 2017.06
1.5.x
1.5.0.RELEASE 4.3.6.RELEASE 2017.01
1.5.1.RELEASE 4.3.6.RELEASE 2017.01
1.5.2.RELEASE 4.3.7.RELEASE 2017.03
1.5.3.RELEASE 4.3.8.RELEASE 2017.04
1.5.4.RELEASE 4.3.9.RELEASE 2017.06
1.5.5.RELEASE 4.3.10.RELEASE 2017.07
1.5.6.RELEASE 4.3.10.RELEASE 2017.07
1.5.7.RELEASE 4.3.11.RELEASE 2017.09
1.5.8.RELEASE 4.3.12.RELEASE 2017.10
1.5.9.RELEASE 4.3.13.RELEASE 2017.11
1.5.10.RELEASE 4.3.14.RELEASE 2018.01
1.5.11.RELEASE 4.3.15.RELEASE 2018.04
1.5.12.RELEASE 4.3.16.RELEASE 2018.04
1.5.13.RELEASE 4.3.17.RELEASE 2018.05
1.5.14.RELEASE 4.3.18.RELEASE 2018.06
1.5.15.RELEASE 4.3.18.RELEASE 2018.07
1.5.16.RELEASE 4.3.19.RELEASE 2018.09
1.5.17.RELEASE 4.3.20.RELEASE 2018.10
1.5.18.RELEASE 4.3.21.RELEASE 2018.11
1.5.19.RELEASE 4.3.22.RELEASE 2019.01
1.5.20.RELEASE 4.3.23.RELEASE 2019.04
1.5.21.RELEASE 4.3.24.RELEASE 2019.05
1.5.22.RELEASE 4.3.25.RELEASE 2019.08
2.0.x
2.0.0.RELEASE 5.0.4.RELEASE 2018.03
2.0.1.RELEASE 5.0.5.RELEASE 2018.04
2.0.2.RELEASE 5.0.6.RELEASE 2018.05
2.0.3.RELEASE 5.0.7.RELEASE 2018.06
2.0.4.RELEASE 5.0.8.RELEASE 2018.07
2.0.5.RELEASE 5.0.9.RELEASE 2018.09
2.0.6.RELEASE 5.0.10.RELEASE 2018.10
2.0.7.RELEASE 5.0.11.RELEASE 2018.11
2.0.8.RELEASE 5.0.12.RELEASE 2019.01
2.0.9.RELEASE 5.0.13.RELEASE 2019.04
2.1.x
2.1.0.RELEASE 5.1.2.RELEASE 2018.10
2.1.1.RELEASE 5.1.3.RELEASE 2018.11
2.1.2.RELEASE 5.1.4.RELEASE 2019.01
2.1.3.RELEASE 5.1.5.RELEASE 2019.02
2.1.4.RELEASE 5.1.6.RELEASE 2019.04
2.1.5.RELEASE 5.1.7.RELEASE 2019.05
2.1.6.RELEASE 5.1.8.RELEASE 2019.06
2.1.7.RELEASE 5.1.9.RELEASE 2019.08
2.1.8.RELEASE 5.1.9.RELEASE 2019.09
2.1.9.RELEASE 5.1.10.RELEASE 2019.10
2.1.10.RELEASE 5.1.11.RELEASE 2019.11
2.1.11.RELEASE 5.1.12.RELEASE 2019.12
2.1.12.RELEASE 5.1.13.RELEASE 2020.01
2.1.13.RELEASE 5.1.14.RELEASE 2020.02
2.1.14.RELEASE 5.1.15.RELEASE 2020.05
2.1.15.RELEASE 5.1.16.RELEASE 2020.06
2.1.16.RELEASE 5.1.17.RELEASE 2020.07
2.1.17.RELEASE 5.1.18.RELEASE 2020.09
2.1.18.RELEASE 5.1.19.RELEASE 2020.10
2.2.x
2.2.0.RELEASE 5.2.0.RELEASE 2019.10
2.2.1.RELEASE 5.2.1.RELEASE 2019.11
2.2.2.RELEASE 5.2.2.RELEASE 2019.12
2.2.3.RELEASE 5.2.3.RELEASE 2020.01
2.2.4.RELEASE 5.2.3.RELEASE 2020.01
2.2.5.RELEASE 5.2.4.RELEASE 2020.02
2.2.6.RELEASE 5.2.5.RELEASE 2020.03
2.2.7.RELEASE 5.2.6.RELEASE 2020.05
2.2.8.RELEASE 5.2.7.RELEASE 2020.06
2.2.9.RELEASE 5.2.8.RELEASE 2020.07
2.2.10.RELEASE 5.2.9.RELEASE 2020.09
2.2.11.RELEASE 5.2.10.RELEASE 2020.10
2.2.12.RELEASE 5.2.12.RELEASE 2020.11
2.2.13.RELEASE 5.2.12.RELEASE 2021.01
2.3.x
2.3.0.RELEASE 5.2.6.RELEASE 2020.05
2.3.1.RELEASE 5.2.7.RELEASE 2020.06
2.3.2.RELEASE 5.2.8.RELEASE 2020.07
2.3.3.RELEASE 5.2.8.RELEASE 2020.08
2.3.4.RELEASE 5.2.9.RELEASE 2020.09
2.3.5.RELEASE 5.2.10.RELEASE 2020.10
2.3.6.RELEASE 5.2.11.RELEASE 2020.11
2.3.7.RELEASE 5.2.12.RELEASE 2020.12
2.3.8.RELEASE 5.2.12.RELEASE 2021.01
2.3.9.RELEASE 5.2.13.RELEASE 2021.02
2.3.10.RELEASE 5.2.14.RELEASE 2021.04
2.3.11.RELEASE 5.2.15.RELEASE 2021.05
2.3.12.RELEASE 5.2.15.RELEASE 2021.06
2.4.x
2.4.0 5.3.1 2020.11
2.4.1 5.3.2 2020.12
2.4.2 5.3.3 2021.01
2.4.3 5.3.4 2021.02
2.4.4 5.3.5 2021.03
2.4.5 5.3.6 2021.04
2.4.6 5.3.7 2021.05
2.4.7 5.3.8 2021.06
2.4.8 5.3.8 2021.06
2.4.9 5.3.9 2021.07
2.4.10 5.3.9 2021.08
2.4.11 5.3.10 2021.09
2.4.12 5.3.12 2021.10
2.4.13 5.3.13 2021.11
2.5.x
2.5.0 5.3.7 2021.05
2.5.1 5.3.8 2021.06
2.5.2 5.3.8 2021.06
2.5.3 5.3.9 2021.07
2.5.4 5.3.9 2021.08
2.5.5 5.3.10 2021.09
2.5.6 5.3.12 2021.10
2.5.7 5.3.13 2021.11
2.5.8 5.3.14 2021.12
2.6.x
2.6.0 5.3.13 2021.11
2.6.1 5.3.13 2021.11
2.6.2 5.3.14 2021.12
2.6.3 5.3.15 2022.01
2.6.4 5.3.16 2022.02
2.6.5 5.3.17 2022.03
2.6.6 5.3.18 2022.03
2.6.7 5.3.19 2022.04
2.6.8 5.3.20 2022.05
2.6.9 5.3.21 2022.06
2.7.x
2.7.0 5.3.20 2022.05
2.7.1 5.3.21 2022.06

通过上述表格的对应关系,springboot2.6.6版本默认依赖的spring framework版本为5.3.18,所以可以通过升级springboot版本来升级spring framework的版本。

方法一:

如果项目的parent中使用的是spring-boot-starter-parent,那么可以直接修改该版本号为2.6.6

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

方法二:

如果parent中使用的是其他父依赖,那么可以通过在pom文件中添加spring-boot.version解决

<properties> <spring-boot.version>2.6.6</spring-boot.version> </properties>

遇到的问题:

  1. jackson-databind包版本不兼容:
    org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) at ***.x5dtech.dwsim.Application.main(Application.java:21) Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:478) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ... 8 ***mon frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'formContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]: Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [***.fasterxml.jackson.datatype.jsr310.JavaTimeModule]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: ***/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerializer at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:175) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:170) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:155) at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:87) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:260) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234) at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ... 13 ***mon frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedFormContentFilter]: Factory method 'formContentFilter' threw exception; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [***.fasterxml.jackson.datatype.jsr310.JavaTimeModule]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: ***/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerializer at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ... 56 ***mon frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [***.fasterxml.jackson.datatype.jsr310.JavaTimeModule]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: ***/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerializer at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:146) at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:832) at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:691) at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:674) at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:59) at org.springframework.http.converter.support.AllEn***passingFormHttpMessageConverter.<init>(AllEn***passingFormHttpMessageConverter.java:91) at org.springframework.web.filter.FormContentFilter.<init>(FormContentFilter.java:61) at org.springframework.boot.web.servlet.filter.OrderedFormContentFilter.<init>(OrderedFormContentFilter.java:29) at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.formContentFilter(WebMvcAutoConfiguration.java:179) at sun.reflect.NativeMethodA***essorImpl.invoke0(Native Method) at sun.reflect.NativeMethodA***essorImpl.invoke(NativeMethodA***essorImpl.java:62) at sun.reflect.DelegatingMethodA***essorImpl.invoke(DelegatingMethodA***essorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 57 ***mon frames omitted Caused by: java.lang.NoClassDefFoundError: ***/fasterxml/jackson/datatype/jsr310/ser/ZoneIdSerializer at ***.fasterxml.jackson.datatype.jsr310.JavaTimeModule.<init>(JavaTimeModule.java:158) at sun.reflect.NativeConstructorA***essorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorA***essorImpl.newInstance(NativeConstructorA***essorImpl.java:62) at sun.reflect.DelegatingConstructorA***essorImpl.newInstance(DelegatingConstructorA***essorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211) ... 71 ***mon frames omitted

    解决方式:通过在该网站中查找jackson-databind,找到推荐的版本,修改后解决 Spring Boot Reference Documentation

  2. pagehelper循环依赖:
    ***.github.pagehelper.autoconfigure.PageHelperAutoConfiguration

​ 解决方式:由于springboot2.6禁止循环依赖导致,升级到1.4.1解决

2.maven项目

对于maven项目,我通过dependencyManagement标签直接升级了spring framework:

<dependencyManagement> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.3.18</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.3.18</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.3.18</version> </dependency> </dependencyManagement>

3.总结
  1. springboot项目可通过升级springboot版本来升级默认依赖的spring framework版本
  2. maven项目可直接在标签中直接指定spring framework相关依赖的版本
转载请说明出处内容投诉
CSS教程_站长资源网 » Spring Framework版本升级

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买