解决 Shiro 重复调用 doGetAuthenticationInfo 导致异常处理错误的问题

遇到一个 Shiro 中反复调用 doGetAuthenticationInfo 导致异常没有被成功处理的问题,经过一些源码调试,发现了问题的所在,只需在继承 BasicHttpAuthenticationFilter 的类中重写 onAccessDenied 方法即可。


文章目录

  • 1.问题环境
  • 2.问题描述
  • 3.问题调试
  • 4.问题解决


1.问题环境

  • Springboot 3.1.5
  • Shiro 1.12.0

2.问题描述

在自己的 MyReal 类中,重写了 doGetAuthenticationInfo 方法:

    @Overrideprotected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {String token = (String) auth.getCredentials();if (token == null) {HttpServletRequest req = SpringContextUtils.getHttpServletRequest();throw new AuthenticationException("token为空!");}// 校验token有效性LoginUser loginUser = this.checkUserTokenIsEffect(token);return new SimpleAuthenticationInfo(loginUser, token, getName());}

在继承 BasicHttpAuthentication Filter的类JwtFilter中重写了isAccessAllowed方法和executeLogin方法:

@Overrideprotected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {try {executeLogin(request, response);return true;} catch (Exception e) {JwtUtil.responseError(response,401,CommonConstant.TOKEN_IS_INVALID_MSG);return false;}}

现在的问题是:
当 token 为空时,抛出了new AuthenticationException("token为空!");的异常,这个异常被JwtFilter中的isAccessAllowed捕获了,并且提交了 response。

但是神奇的是,isAccessAllowed方法返回 false 后,又调用了 MyReal 类中的doGetAuthenticationInfo 方法,这个方法继续抛出异常,此时这个授权异常没有被正常处理,最后进入了全局异常处理的handler中,而此时 response 已经被提交了,于是就又导致了其它的异常。如下所示:(关键类路径被脱敏了)

org.apache.shiro.authc.AuthenticationException: token为空!at *.ShiroRealm.doGetAuthenticationInfo(ShiroRealm.java:90)at org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:571)at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:180)at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:273)at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)at org.apache.shiro.mgt.DefaultSecurityManager.login(DefaultSecurityManager.java:275)at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:260)at *.JwtFilter.executeLogin(JwtFilter.java:76)at org.apache.shiro.web.filter.authc.HttpAuthenticationFilter.onAccessDenied(HttpAuthenticationFilter.java:230)at org.apache.shiro.web.filter.AccessControlFilter.onAccessDenied(AccessControlFilter.java:133)at org.apache.shiro.web.filter.AccessControlFilter.onPreHandle(AccessControlFilter.java:162)at org.apache.shiro.web.filter.PathMatchingFilter.isFilterChainContinued(PathMatchingFilter.java:223)at org.apache.shiro.web.filter.PathMatchingFilter.preHandle(PathMatchingFilter.java:198)at *.JwtFilter.preHandle(JwtFilter.java:117)at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:131)at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:458)at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:373)at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:370)at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:352)at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:268)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.base/java.lang.Thread.run(Thread.java:842)org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.LinkedHashMap] with preset Content-Type 'text/json;charset=UTF-8'at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:319)at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:245)at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:78)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:136)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564)at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:642)at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:520)at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:463)at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:343)at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:222)at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:308)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:149)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.base/java.lang.Thread.run(Thread.java:842)
2024-07-24 16:56:00.079  WARN 71569 --- [                                    ] [                   ] [               ] [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver 419    : Failure in @ExceptionHandler *.GlobalExceptionHandler#handleException(Exception)org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class *.Result] with preset Content-Type 'text/json;charset=UTF-8'at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:319)at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:194)at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:78)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:136)at org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver.doResolveHandlerMethodException(ExceptionHandlerExceptionResolver.java:413)at org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionResolver.doResolveException(AbstractHandlerMethodExceptionResolver.java:74)at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:141)at org.springframework.web.servlet.handler.HandlerExceptionResolverComposite.resolveException(HandlerExceptionResolverComposite.java:80)at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1341)at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1152)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1098)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564)at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:642)at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:520)at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:463)at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:343)at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:222)at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:308)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:149)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.base/java.lang.Thread.run(Thread.java:842)2024-07-24 16:56:00.083  WARN 71569 --- [                                    ] [                   ] [               ] [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver 207    : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class java.util.LinkedHashMap] with preset Content-Type 'text/json;charset=UTF-8']

3.问题调试

关键位置打上断点:
在这里插入图片描述
在这里插入图片描述
经过调试可以发现,第一次的异常被捕获处理后,isAccessAllowed方法返回 false ,然后进入AccessControlFilter类的onPreHandle方法中:
在这里插入图片描述
继续调试,可以发现又进入了onAccessDenied方法中,而其中又会调用executeLogin方法,又重复进入了MyReal 类中的doGetAuthenticationInfo 方法,此时再次抛出异常,这个异常已经不能被正确处理了。
在这里插入图片描述

4.问题解决

可以发现,问题的根本在于onAccessDenied方法中会调用executeLogin方法,又重复进入了MyReal 类中的doGetAuthenticationInfo 方法。我们只需重写onAccessDenied方法即可解决此问题。

在在继承 BasicHttpAuthenticationFilter的类JwtFilter中重写onAccessDenied方法:

@Overrideprotected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {this.sendChallenge(request, response);return false;}

至此问题完美解决!


ATFWUS 2024-07-24

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

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

相关文章

2024-07-23 Unity AI行为树2 —— 项目介绍

文章目录 1 项目介绍2 AI 代码介绍2.1 BTBaseNode / BTControlNode2.2 动作/条件节点2.3 选择 / 顺序节点 3 怪物实现4 其他功能5 UML 类图 项目借鉴 B 站唐老狮 2023年直播内容。 点击前往唐老狮 B 站主页。 1 项目介绍 ​ 本项目使用 Unity 2022.3.32f1c1,实现基…

25.x86游戏实战-理解发包流程

免责声明:内容仅供学习参考,请合法利用知识,禁止进行违法犯罪活动! 本次游戏没法给 内容参考于:微尘网络安全 工具下载: 链接:https://pan.baidu.com/s/1rEEJnt85npn7N38Ai0_F2Q?pwd6tw3 提…

【iOS】——Block循环引用

循环引用原因 如果在Block中使用附有_ _strong修饰符的对象类型自动变量,那么当Block从栈复制到堆时,该对象为Block所持有,这样容易引起循环引用。 HPPerson *person [[HPPerson alloc] init];person.block ^{NSLog("person.age--- …

服务韧性工程(SRE)论坛演讲实录 | 雅菲奥朗: 人工智能的未来之路引领智能运维新纪元

2024年5月24日,第二届服务韧性工程(SRE)论坛在杭州成功举办。本次会议由中关村人才协会作为指导单位,中国移动通信集团浙江有限公司和SRE创新联合体(中关村人才协会SRE专委会)联合主办,中移动信息技术有限公…

Linux 某进程 CPU 高问题,用 Shell 脚本发现处理

发现高CPU使用率进程 首先,我们需要编写一个Shell脚本来发现系统中CPU使用率最高的进程。以下是一个简单的脚本示例: #!/bin/bash# 设置 CPU 使用率的阈值,一般设置90;这里是demo,所以用30 CPU_THRESHOLD30# 获取占用 CPU 最高的…

pikauchu之Unsafe Fileupload(不安全的文件上传)

Client check&#xff08;客户检查&#xff09; 第一步先新建一个一句话木马 <?php eval($_POST[1]);?> 然后上传文件 有限制&#xff0c;只能上传那几种类型 现在看看源代码 我们将一句话木马文件的后缀改为png 然后用burp抓包&#xff0c;将png改成php 就能上传成功 …

运维上云/直播上云EasyNVS视频上云管理平台配置域名时的注意事项

EasyNVS视频上云管理平台拥有完整的视频流媒体服务能力和运维管理服务能力&#xff0c;不仅可以通过平台对EasyNVR、EasyGBS进行统一管理&#xff0c;还能解决设备现场没有固定公网IP却需要在公网直播的需求。 有用户反馈&#xff0c;在项目现场配置了EasyNVS的HTTPS证书&#…

Studying-代码随想录训练营day44| 1143.最长公共子序列、1035.不相交的线、53.最大子序和、392.判断子序列

第44天&#xff0c;动态规划part11&#xff0c;子序列题型part02(ง •_•)ง&#x1f4aa;&#xff0c;编程语言&#xff1a;C 目录 1143.最长公共子序列 1035.不相交的线 53.最大子序和 392.判断子序列 总结 1143.最长公共子序列 文档讲解&#xff1a;代码随想录最长公…

【微信小程序实战教程】之微信小程序原生开发详解

微信小程序原生开发详解 微信小程序的更新迭代非常频繁&#xff0c;几乎每个月都会有新版本发布&#xff0c;这就会让初学者感觉到学习的压力和难度。其实&#xff0c;我们小程序的每次版本迭代都是在现有小程序架构基础之上进行更新的&#xff0c;如果想要学好小程序开发技术&…

面试经典 114. 二叉树展开为链表

最近工作越来越难找&#xff0c;裁员越来越懂了&#xff0c;焦虑的睡不着&#xff0c;怎么办呢&#xff0c;只能刷面试题&#xff0c;卷死你们 今天这个题目没刷过&#xff0c;我思考了半天才只能用暴力&#xff0c;后来苦思冥想才想出来简单的方法&#xff0c;废话不多说&…

【机器学习】激活函数:神经网络的灵魂

&#x1f308;个人主页: 鑫宝Code &#x1f525;热门专栏: 闲话杂谈&#xff5c; 炫酷HTML | JavaScript基础 ​&#x1f4ab;个人格言: "如无必要&#xff0c;勿增实体" 文章目录 激活函数&#xff1a;神经网络的灵魂什么是激活函数?常见激活函数类型1. Sigmo…

深入了解 JMeter 中的响应断言

JMeter 是一个强大的性能测试工具&#xff0c;能够模拟大量用户并发访问网站或应用程序&#xff0c;以便测试其性能和稳定性。在进行性能测试时&#xff0c;我们需要对响应结果进行断言&#xff0c;以确保应用程序或网站的功能和性能符合预期。 JMeter 提供了一套丰富的响应断…

VINS-FUSION 优化-IMU预积分因子(二)

VINS-FUSION 优化-IMU预积分因子(一)完成了IMU预积分及对于优化变量的全部雅克比矩阵的推导,本文结合VINS-FUSION源码,完成优化-IMU预积分因子的使用。 一、IMU预积分因子雅克比 VINS-FUSION源码中将优化变量分组如下: 1.对i时刻优化变量的雅可比

8.0.32 mysql 配置主从数据库

配置前提&#xff1a; 两台服务器都需要安装同一版本的mysql数据库 我的版本是8.0.32 数据库参数修改 主数据库my.cnf(linux)或my.ini(win)配置&#xff1a; 这里需要注意&#xff1a;server-id必须唯一主从两个库必须要不一样 log_binmysql-bin server-id24 gtid-modeON …

chapter08-面相对象编程的三大特征——封装

1、基础介绍 对电视机的操作就是典型封装 封装的好处&#xff1a;隐藏实现细节&#xff1b;可以对数据进行验证 2、封装的实现 3、入门案例 altinsert&#xff0c;getter and setter&#xff0c;自动插入

生成式人工智能的未来之路:对话系统与自主代理的交汇与展望

✨✨ 欢迎大家来访Srlua的博文&#xff08;づ&#xffe3;3&#xffe3;&#xff09;づ╭❤&#xff5e;✨✨ &#x1f31f;&#x1f31f; 欢迎各位亲爱的读者&#xff0c;感谢你们抽出宝贵的时间来阅读我的文章。 我是Srlua小谢&#xff0c;在这里我会分享我的知识和经验。&am…

RAS--APEI 报错解析流程(2)

RAS--APEI 报错解析流程(1) 除了APEI 中除了GHES会记录错误&#xff0c;在Post过程中的错误通常是通过BERT Table汇报 1.BERT Boot Error Record Table is used to report unhandled errors that occurred in a previous boot&#xff0c;it is reported as a ‘one-time polle…

HarmonyOS Next 省市区级联(三级联动)筛选框

效果图 完整代码 实例对象 export class ProvinceBean {id?: stringpid?: stringisSelect?: booleandeep?: objectextName?: stringchildren?: ProvinceBean[] }级联代码 import { MMKV } from tencent/mmkv/src/main/ets/utils/MMKV import { ProvinceBean } from ..…

基于 HTML+ECharts 实现智慧运维数据可视化大屏(含源码)

智慧运维数据可视化大屏&#xff1a;基于 HTML 和 ECharts 的实现 在现代企业中&#xff0c;运维管理是确保系统稳定运行的关键环节。随着数据量的激增&#xff0c;如何高效地监控和分析运维数据成为了一个重要课题。本文将介绍如何利用 HTML 和 ECharts 实现一个智慧运维数据可…

深入理解 Java NIO:ByteBuffer和MappedByteBuffer的特性与使用

目录 前言 ByteBuffer是什么 重要特点 分配缓冲区 读写模式切换 操作文本数据 操作基本数据类型 案例解析-循环输出数据 MappedByteBuffer是什么 MappedByteBuffer 的工作机制 刷盘时机 总结 前言 在深入学习 RocketMQ 这款高性能消息队列框架的源码时&#xff0c…