我服了!SpringBoot升级后这服务我一个星期都没跑起来!(下)

news2024/10/7 4:22:31

14. DiscoveryEnabledServer Not Found

主要问题还是 eureka 中没有了 ribbon 相关的依赖。

Caused by: java.lang.NoClassDefFoundError: com/netflix/niws/loadbalancer/DiscoveryEnabledServer
	at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?]
	at java.lang.Class.privateGetDeclaredMethods(Class.java:3167) ~[?:?]
	at java.lang.Class.getDeclaredMethods(Class.java:2310) ~[?:?]
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.23.jar:5.3.23]
	at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321) ~[spring-core-5.3.23.jar:5.3.23]
复制代码

解决方案:手动引入相关依赖包。

<dependency>
  <groupId>com.netflix.ribbon</groupId>
  <artifactId>ribbon-loadbalancer</artifactId>
  <version>2.7.18</version>
</dependency>
<dependency>
  <groupId>com.netflix.ribbon</groupId>
  <artifactId>ribbon-eureka</artifactId>
  <version>2.7.18</version>
</dependency>
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
  <version>2.2.10.RELEASE</version>
</dependency>
复制代码

15. 中间件循环依赖

依然是循环依赖报错,之前没注意看代码,简单的设置了一下为延迟初始化,仔细一看发现代码这样写的,你细品。

然后启动报错:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cachesEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/cache/CachesEndpointAutoConfiguration.class]: Unsatisfied dependency expressed through method 'cachesEndpoint' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Requested bean is currently in creation: Is there an unresolvable circular reference?
复制代码

16. CacheMetricsRegistrarConfiguration 报错

由于在解决 15 的问题一开始是设置为延迟初始化,然后启动发现仍然报错。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration]: Constructor threw exception; nested exception is java.lang.StackOverflowError
复制代码

解决方案:去掉 Autowired 注入,15和16的问题全部解决。

17. kafka-clients 版本和 spring-kafka 不兼容

升级后默认spring-kafka是2.8.10版本,KafkaTemplate 报错找不到类,原因在于本地kafka-clients使用的是 2.3.0 版本。

Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.kafka.core.KafkaTemplate] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@9e89d68]
Caused by: java.lang.NoClassDefFoundError: org/apache/kafka/clients/consumer/ConsumerGroupMetadata
复制代码

解决方案:kafka-clients升级到兼容版本 3.0.2 ,这个版本是 spring-cloud-dependency 中依赖的版本。

18. swagger启动报错

这个报错是因为新版本 Spring Boot 将 Spring MVC 默认路径匹配策略由AntPathMatcher改成了PathPatternParser,这个报错在我这里是WARN,而且非常隐蔽,需要仔细查找。

[WARN] [2022.11.08 16:17:39.963] [10.135.0.95] [] [main] [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext()] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
复制代码

解决方案:配置成原来的AntPathMatcher,添加配置spring.mvc.pathmatch.matching-strategy= ANT_PATH_MATCHER

这个报错信息是一行 WARN 日志,非常难找,另外原因是根据网上信息搜索定位到的,这个报错信息我真的服了。

19. spring-session依赖报错

启动报错信息:

n attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$ServletSessionConfiguration.cookieSerializer(SessionAutoConfiguration.java:109)

The following method did not exist:

    'void org.springframework.session.web.http.DefaultCookieSerializer.setSameSite(java.lang.String)'

The calling method's class, org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$ServletSessionConfiguration, was loaded from the following location:

    jar:file:/Users/user/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.7.5/spring-boot-autoconfigure-2.7.5.jar!/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration$ServletSessionConfiguration.class

The called method's class, org.springframework.session.web.http.DefaultCookieSerializer, is available from the following locations:

    jar:file:/Users/user/.m2/repository/org/springframework/session/spring-session/1.3.5.RELEASE/spring-session-1.3.5.RELEASE.jar!/org/springframework/session/web/http/DefaultCookieSerializer.class
复制代码

spring-session使用的是1.3.5.RELEASE,但是打开 Maven 仓库一看,这居然是最新版本?而且还是 2019 年的版本?

其实并非如此,查找 Github 代码后发现是代码做了模块化拆分,新版本应该引入spring-session-core

<dependency>
    <groupId>org.springframework.session</groupId>
    <artifactId>spring-session-core</artifactId>
    <version>2.7.0</version>
</dependency>
复制代码

20. spring-security版本兼容问题

在看到 SessionAutoConfiguration里面代码同时发现spring-security相关依赖代码发生了改变。

解决方案:引入最新版本spring-security-web

<dependency>
  <groupId>org.springframework.security</groupId>
  <artifactId>spring-security-web</artifactId>
  <version>5.7.4</version>
</dependency>
复制代码

21. RibbonLoadBalancerClient启动报错

报错信息:

org.springframework.retry.RetryException: Could not recover; nested exception is java.lang.AbstractMethodError: Receiver class org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient does not define or inherit an implementation of the resolved method abstract choose(Ljava/lang/String;Lorg/springframework/cloud/client/loadbalancer/Request;)Lorg/springframework/cloud/client/ServiceInstance; of interface org.springframework.cloud.client.loadbalancer.ServiceInstanceChooser.
复制代码

原因在于位于spring-cloud-commons里面的ServiceInstanceChooser#choose方法发生了改变。

而我们由于为了继续使用spring-cloud-netflix-ribbon包,引入的只能是更新到2021年的最新版本2.2.10.RELEASE,这个包最后更新时间是 2021年11月份,所以这里面实现的仍然是老的choose方法。

解决方案:使用同 package 名方式自己重写该类,choose 方法的逻辑其实是和原来传参 object 方法一样的,或者自己把包拉下来改代码重新打包。

22. MongoDB报错

spring-boot-autoconfigure新版本下MongoClientFactory构造函数发生改变,以前的写法发生编译错误。

以前的这种写法传参是MongoProperties

return new MongoClientFactory(mongoProperties).createMongoClient(mongoClientOptions());
复制代码

现在的写法:

MongoClientSettingsBuilderCustomizer customizer = new MongoPropertiesClientSettingsBuilderCustomizer(mongoProperties, environment);
return new MongoClientFactory(Lists.newArrayList(customizer)).createMongoClient(mongoClientOptions());
复制代码

另外一个问题是原来的createMongoClient传参是 MongoClientOptions,现在是 MongoClientSettings。

原来使用heartbeatFrequencyheartbeatConnectTimeout等等一些写法也不一样了,示意一下现在的写法:

MongoClientSettings.builder()
  .applyToServerSettings(builder -> builder.heartbeatFrequency(8000, TimeUnit.MILLISECONDS))
  .applyToConnectionPoolSettings(builder -> builder.maxConnectionIdleTime(30000,TimeUnit.MILLISECONDS))
  .applyToSocketSettings(builder -> builder.connectTimeout(30000,TimeUnit.MILLISECONDS))
  .build();
复制代码

另外,如果使用到了 morphia 的话,这个改动就更大了,基本老代码没法用了,尝试了一下,改不动,暂时放弃了。

总结

事情基本到这里就暂时告一段落了,有一些老的代码改动太大,基本要废弃重写了,暂时搁置吧。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/28047.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

论文笔记(二十二):GRiD: GPU-Accelerated Rigid Body Dynamics with Analytical Gradients

GRiD: GPU-Accelerated Rigid Body Dynamics with Analytical Gradients文章概括摘要1. 介绍2. 相关工作3. 背景A. *计算硬件&#xff1a;CPU vs. GPU*B. 刚体动力学4. GRiD库A. 设计B. 当前特征C. 代码优化方法5. 性能基准A. 方法B. 多重计算延时C. 单一计算延时扩展6. 结论和…

母线电容及其计算方法

母线电容及其计算方法 1.母线电容是什么&#xff1f; 2.母线电容有什么作用&#xff1f; 3.母线电容的参数。 4.母线电容参数计算。 1.母线电容是什么&#xff1f; 工程定义&#xff1a; &#xff08;1&#xff09;在电机控制器中&#xff0c;电池包的直流电作为输入电源&am…

关于 SAP ABAP SYSTEM_SHM_OPEN_CHANGE_LOCK 运行时错误的问题

有朋友在技术讨论群里提问&#xff1a; 遇到 SYSTEM_SHM_OPEN_CHANGE_LOCK 的运行时错误&#xff1a;Open change lock on transactional area in COMMIT: 上图显示&#xff0c;错误在 SAP ABAP 标准程序 SAPMHTTP 里抛出&#xff0c;这说明是 ABAP 服务器进行 HTTP 请求处理或…

SpringBoot SpringBoot 开发实用篇 5 整合第三方技术 5.23 SpringBoot 整合 RabbitMQ(direct 模式)

SpringBoot 【黑马程序员SpringBoot2全套视频教程&#xff0c;springboot零基础到项目实战&#xff08;spring boot2完整版&#xff09;】 SpringBoot 开发实用篇 文章目录SpringBootSpringBoot 开发实用篇5 整合第三方技术5.23 SpringBoot 整合 RabbitMQ(direct 模式)5.23.1…

web前端期末大作业——基于html+css+javascript+jquery+bootstrap响应式户外旅游网站

&#x1f468;‍&#x1f393;学生HTML静态网页基础水平制作&#x1f469;‍&#x1f393;&#xff0c;页面排版干净简洁。使用HTMLCSS页面布局设计,web大学生网页设计作业源码&#xff0c;这是一个不错的旅游网页制作&#xff0c;画面精明&#xff0c;排版整洁&#xff0c;内容…

分析高数值孔径物镜的聚焦

摘要 高数值孔径物镜广泛用于光学光刻、显微镜等。因此&#xff0c;在聚焦模拟中考虑光的矢量性质是非常重要的。 VirtualLab非常容易支持这种镜头的光线和光场追迹分析。 通过光场追迹&#xff0c;可以清楚地展示不对称焦斑&#xff0c;这源于矢量效应。 照相机探测器和电磁场…

解决台式机麦克风不可用问题,只有音频输出,无音频输入

解决台式机麦克风不可用问题 戴尔灵越3880 最近因为需要开线上会议&#xff0c;发现戴尔台式机音频只有输出没有输入&#xff0c;也就是只能听见声音&#xff0c;无法输入声音。 先后尝试了各种驱动安装更新之类的调试&#xff0c;无果。 之后通过戴尔支持解决~ 这里多说一…

京东主图视频上传,如何关联商品投放?

京东主图视频怎么做&#xff0c;如何上传主图视频&#xff1f;大家都知道商品可以展示五张主图&#xff0c;主图可以帮助买家更好地了解产品卖点。而主图视频可以更全面的展示产品&#xff0c;对此京麦还设置了不同类型的视频模板&#xff0c;但是很多新手商家往往在上传视频的…

适配器模式(Gateway中GatewayFilter和GlobalFilter整合实现)

文章目录GlobalFilter(代表全局过滤器)GatewayFilter(代表路由过滤器)GlobalFilterAdapter(适配器关键)测试类执行结果在SpringCloud Gateway中有两个不同的过滤器接口&#xff0c;分别是GatewayFilter和GlobalFilter。 GlobalFilter&#xff1a;全局过滤器。不需要再配置文件…

在外公网调阅公司内网资料文件【内网穿透】

优盘体积小巧重量轻&#xff0c;是不少人移动存储数据的首选。但优盘虽然方便携带&#xff0c;但也正是因为小巧和轻便&#xff0c;导致一不留神就会丢失&#xff0c;并且存储的数据也会有损坏的风险&#xff0c;因此在云存储概念兴起后&#xff0c;就快速成为数据存储的新风尚…

网络安全之反序列化漏洞复现

0x01 Apereo cas简介 Apereo CAS 单点登陆系统是Java服务器环境下使用较为广泛的单点登陆系统。 CAS 全程Central Authentication Service&#xff08;中心认证服务&#xff09;&#xff0c;是一个单点登录协议&#xff0c;Apereo CAS是实现该协议的软件包。 单点登录定义 …

【面试】Android 大厂必问的8大模块,你掌握了几个?

自15年毕业进入社会从事 Android 开发行业&#xff0c;&#xff0c;已经将近有八年的时光了&#xff1b; 在这将近八年的时间内&#xff0c; 我从 小厂打杂到进入到核心团队&#xff0c;再跳槽到大厂&#xff1b; 在华为呆过一段时间&#xff0c;18年四月份进了阿里一直到现在&…

体态识别算法在 Android 端部署实例

背景介绍 随着软硬件技术的发展&#xff0c;智能穿戴式设备逐渐从概念走向商用化。在过去几年内&#xff0c;Google、Apple以及Sony等科技公司在体积、功耗控制以及成本等方面做得越来越好&#xff0c;推出了一大批可穿戴产品&#xff0c;具有代表性的成果有&#xff1a;1. 智能…

Cy5 Alkyne,1223357-57-0,花青素Cyanine5炔基用于点击化学标记反应

CAS号&#xff1a;1223357-57-0 | 英文名&#xff1a; Cyanine5 alkyne&#xff0c;Cy5 Alkyne | 中文名&#xff1a;花青素CY5炔基 CASNumber&#xff1a;1223357-57-0 Molecular formula&#xff1a;C35H42ClN3O Molecular weight&#xff1a;556.19 Purity&#xff1a;9…

【CNN】ResNet——开启的深度学习从1到无限可能的新时代

前言 深度残差网络&#xff08;Deep residual network, ResNet&#xff09;的提出是CNN图像史上的一件里程碑事件&#xff0c;ResNet在2015年发表当年取得了图像分类&#xff0c;检测等等5项大赛第一&#xff0c;并又一次刷新了CNN模型在ImageNet上的历史记录。直到今天&#…

《看漫画学Python》1、2版分享,python最佳入门教程,中学生用业余时间都能学会,北大教授看完都这样定义它

前言 学习Python的小伙伴大部分应该都知道《看漫画学Python&#xff1a;有趣、有料、好玩、好用&#xff08;全彩版&#xff09;》这本书&#xff01; 但是刚开始接触Python的朋友都会有一个共同的烦恼&#xff0c;自学好无聊&#xff0c;好枯燥&#xff0c;不想坚持了……所…

Ajax使用

简介&#xff1a; 全称:Asynchronous JavaScript And XML 中文名:异步js与XML 作用:网页使用JavaScript脚本实现前端与服务器的异步交互技术,可以在不刷新网页的前 提下实现和服务器的数据交互 注意:ajax不是一种编程语言&#xff0c;而是使用JS的一种技术。 使用步骤 步骤&am…

最佳镜像搬运工 Skopeo 指南

最佳镜像搬运工 Skopeo 指南 文章目录最佳镜像搬运工 Skopeo 指南1. 概述2. Skopeo 是如何工作的&#xff1f;3. 为什么要用 Skopeo&#xff1f;3.1 灵活性3.2 安全性和可访问性3.3 功能多样性4. 安装4.1 Fedora4.2 RHEL / CentOS Stream ≥ 84.3 RHEL/CentOS ≤ 7.x4.4 Ubuntu…

GPU显存占满但利用率却很低

来帕多瓦联培已经一个多月了&#xff0c;最近调代码跑实验又发现了这个问题。这里提供另外一个解决思路。一个原因还是 cpu没跟上gpu节奏。 通常我们都会用尽可能大的 batch 来占满显存。但是如果cpu的读取和传输跟不上的话就会导致gpu利用率时上时下&#xff0c;而且训练时间…

2022.3IDEA配置grep console

首先安装Grep Console (这个大家都会吧) 安装之后 打开File 选项的Setting→Other Settings→Grep Console 3. 打开之后默认的样式是下图&#xff08;我做了一下标识&#xff09; whole line:是否一整行都是这个样式。用于区分一个关键字和一行字case insensitive: 不勾选就行…