解决updateByExample时属性值异常的问题(部分属性值没有使用占位符?进行占位,而是变成了属性的名称)

目录

    • 场景简介
    • 代码片断
      • 实体类
    • 报错信息
    • 排查
    • 原因
    • 解决
      • 测试过程
      • 解决方案


场景简介

1、程序将mybatis框架升级为3.5.9版本后执行updateByExample方法时报错


代码片断

Condition condition = new Condition(MbCcsSessionConfig.class);
condition.createCriteria().andEqualTo("vdnId", SecurityAuthenUtil.getVdnId());
int row = mbCcsSessionConfigService.updateByExample(param, condition);

实体类

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "t_mb_ccs_session_config")
public class MbCcsSessionConfig  {
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name = "vdnId")
	private Integer vdnId;
	
	@Column(name = "sessionExceptionOverTime")
	private Integer sessionExceptionOverTime = 10;
	
	@Column(name = "sessionExceptionAgentOverTime")
	private Integer sessionExceptionAgentOverTime = 30;
	
	@Column(name = "sessionExceptionOpenOverTime")
	private Integer sessionExceptionOpenOverTime = 20;
	
	@Column(name = "sessionNoStaffOverTime")
	private Integer sessionNoStaffOverTime = 5;
	
	@Column(name = "leaveSessionOverTime")
	private Integer leaveSessionOverTime = 50;
	
	@Column(name = "leaveAgentOverTime")
	private Integer leaveAgentOverTime = 3;
	
	@Column(name = "sessionQueueOverTime")
	private Integer sessionQueueOverTime = 60;
	
	@Column(name = "lastUpdateOper")
	private String lastUpdateOper;
	
	@Column(name = "lastUpdateDate")
	private Date lastUpdateDate;
	
	@Column(name = "leaveSessionAgentOverTime")
	private Integer leaveSessionAgentOverTime;

}

报错信息

2024-05-22 17:37:20.999 - [DEBUG] - [http-nio-8966-exec-10] - [c.f.m.a.MbCcsSessionConfigMapper.updateByExample - line:137]: ==> Preparing: UPDATE t_mb_ccs_session_config SET vdnId = vdnId,sessionExceptionOverTime = ?,sessionExceptionAgentOverTime = ?,sessionExceptionOpenOverTime = ?,sessionNoStaffOverTime = ?,leaveSessionOverTime = ?,leaveAgentOverTime = ?,sessionQueueOverTime = ?,lastUpdateOper = ?,lastUpdateDate = ?,leaveSessionAgentOverTime = ? WHERE ( ( vdnId = ? ) )
2024-05-22 17:37:21.004 - [DEBUG] - [http-nio-8966-exec-10] - [c.f.m.a.MbCcsSessionConfigMapper.updateByExample - line:137]: ==> Parameters: 0(Integer), 0(Integer), 0(Integer), 0(Integer), 0(Integer), 0(Integer), 0(Integer), 1(String), 2024-05-22 17:36:42.597(Timestamp), -1(Integer), 1(Integer)
nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Can not update sharding key, logic table: [t_mb_ccs_session_config], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@8348217].
### The error may exist in com/xxx/mapper/admin/MbCcsSessionConfigMapper.java (best guess)
### The error may involve com.xxx.mapper.admin.MbCcsSessionConfigMapper.updateByExample-Inline
### The error occurred while setting parameters
### SQL: UPDATE t_mb_ccs_session_config  SET vdnId = vdnId,sessionExceptionOverTime = ?,sessionExceptionAgentOverTime = ?,sessionExceptionOpenOverTime = ?,sessionNoStaffOverTime = ?,leaveSessionOverTime = ?,leaveAgentOverTime = ?,sessionQueueOverTime = ?,lastUpdateOper = ?,lastUpdateDate = ?,leaveSessionAgentOverTime = ? WHERE (       (  vdnId = ? ) )
### Cause: org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Can not update sharding key, logic table: [t_mb_ccs_session_config], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@8348217].
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Can not update sharding key, logic table: [t_mb_ccs_session_config], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@8348217].
### The error may exist in com/xxx/mapper/admin/MbCcsSessionConfigMapper.java (best guess)
### The error may involve com.xxx.mapper.admin.MbCcsSessionConfigMapper.updateByExample-Inline
### The error occurred while setting parameters
### SQL: UPDATE t_mb_ccs_session_config  SET vdnId = vdnId,sessionExceptionOverTime = ?,sessionExceptionAgentOverTime = ?,sessionExceptionOpenOverTime = ?,sessionNoStaffOverTime = ?,leaveSessionOverTime = ?,leaveAgentOverTime = ?,sessionQueueOverTime = ?,lastUpdateOper = ?,lastUpdateDate = ?,leaveSessionAgentOverTime = ? WHERE (       (  vdnId = ? ) )
### Cause: org.apache.shardingsphere.underlying.common.exception.ShardingSphereException: Can not update sharding key, logic table: [t_mb_ccs_session_config], column: [org.apache.shardingsphere.sql.parser.sql.segment.dml.assignment.AssignmentSegment@8348217].
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
	at com.sun.proxy.$Proxy119.update(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:288)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:67)
	at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
	at com.sun.proxy.$Proxy246.updateByExample(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:241)
	at com.sun.proxy.$Proxy247.updateByExample(Unknown Source)
	at com.xxx.base.service.impl.BaseServiceImpl.updateByExample(BaseServiceImpl.java:59)
	at com.xxx.controller.admin.sysmanager.SysConfigController.saveCcsSessionConfigInfo(SysConfigController.java:261)
	at com.xxx.controller.admin.sysmanager.SysConfigController$$FastClassBySpringCGLIB$$c230b3da.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:792)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762)
	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:707)
	at com.xxx.controller.admin.sysmanager.SysConfigController$$EnhancerBySpringCGLIB$$3454dab7.saveCcsSessionConfigInfo(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:111)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:337)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at com.xxx.power.jwt.a.doFilterInternal(JwtAuthenticationTokenFilter.java:212)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:126)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:64)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:101)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:367)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:639)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:882)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1647)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	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.lang.Thread.run(Thread.java:750)

排查

查看报错信息,发现打印出来的SQL有问题,update的部分属性值没有使用占位符?进行占位,而是变成了属性的名称

问题就出现在vdnId = vdnId,update时,属性值应该像后边的sessionExceptionOverTime 等属性一样,使用?进行占位的,这里却没有

UPDATE t_mb_ccs_session_config SET vdnId = vdnId,sessionExceptionOverTime = ?,sessionExceptionAgentOverTime = ?,sessionExceptionOpenOverTime = ?,sessionNoStaffOverTime = ?,leaveSessionOverTime = ?,leaveAgentOverTime = ?,sessionQueueOverTime = ?,lastUpdateOper = ?,lastUpdateDate = ?,leaveSessionAgentOverTime = ? WHERE ( ( vdnId = ? ) )

原因

应该是mybatis框架3.5.9版本有与之前的版本有差异导致


解决

测试过程

为什么只有vdnId这个属性有异常,而其他属性却是正常的?

猜测:vdnId是主键,并且存在@Id注解

如果存在@Id注解的字段都不能参与update?那这个版本的mybatis框架还有使用的价值吗?

– 测试一:执行其他业务的updateByExample方法

在这里插入图片描述

结果:updateByExample执行正常


经过前面的测试,update存在多个条件时,就算更新的字段包含了@Id注解的主键,SQL依旧是正常的

– 测试二:为原本执行报错的update逻辑多加一个条件

在这里插入图片描述

结果:updateByExample执行正常


经过测试,发现在update条件只有主键ID的时候SQL才会出现错误


解决方案

– 解决方法一:vdnId字段不参与update

在这里插入图片描述

结果:updateByExample执行正常


– 解决方法二:既然想仅仅根据主键ID进行update,那么可以保留@Id主键,并且使用updateByPrimaryKey方法

在这里插入图片描述

结果:updateByExample执行正常


– 解决方法三:主键ID字段去除@Id注解(不推荐!!!去掉@Id注解会影响到xxxByPrimaryKey等方法的使用)

在这里插入图片描述

结果:updateByExample执行正常

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

知识分享:隔多久查询一次网贷大数据信用报告比较好?

随着互联网金融的快速发展&#xff0c;越来越多的人开始接触和使用网络贷款。而在这个过程中&#xff0c;网贷大数据信用报告成为了评估借款人信用状况的重要依据。那么&#xff0c;隔多久查询一次网贷大数据信用报告比较好呢?接下来随小易大数据平台小编去看看吧。 首先&…

【Python】 Django 框架如何支持百万级日访问量

基本原理 Django 是一个高级的 Python Web 框架&#xff0c;它鼓励快速开发和干净、实用的设计。Django 遵循 MVC&#xff08;模型-视图-控制器&#xff09;设计模式&#xff0c;允许开发者通过编写更少的代码来构建高质量的 Web 应用程序。Django 自带了许多内置功能&#xf…

《最新出炉》系列入门篇-Python+Playwright自动化测试-42-强大的可视化追踪利器Trace Viewer

宏哥微信粉丝群&#xff1a;https://bbs.csdn.net/topics/618423372 有兴趣的可以扫码加入 1.简介 在我们日常执行自动化测试工作的过程中&#xff0c;经常会遇到一些偶发性的bug&#xff0c;但是因为bug是偶发性的&#xff0c;我们不一定每次执行都能复现&#xff0c;所以我…

深度学习模型

深度学习模型 深度学习网络模型是人工智能领域的重要分支&#xff0c;它通过模拟人脑神经网络的工作方式来处理数据并识别模式。以下是对深度学习网络模型的一些主要类型的详细概述&#xff1a; 卷积神经网络&#xff08;Convolutional Neural Network, CNN&#xff09; 结构&a…

【Unity实战篇 】| Unity实现 文本框可以自适应大小,到达最大宽度之后再缩小字体

前言 在文本框可以自适应大小拉伸的前提下,增加一个最大限制宽度,使其到达最大宽度后 再启用 Best Fit 实现自适应改变文字大小以适应文本框的大小。 【Unity实战篇 】 | Unity实现 Text文本框可以自适应大小,到达最大宽度之后再缩小字体 在Unity中经常会用到文本组件的自…

Bonfire - [Asset for Zibra Smoke Fire]

Bonfire资产支持URP、BRP和HDRP渲染管道,可以用作VFX或游戏元素。 这种环境资产可用于增强视觉故事性,以及创建自定义游戏机制,为虚拟世界增加互动性和真实性。 全交互:使用Zibra Smoke&Fire进行实时烟雾模拟。 易于使用:您所需要做的就是购买资产并将其放入场景中。不…

【NOIP2015普及组复赛】题3:求和

题3&#xff1a;求和 【题目描述】 一条狭长的纸带被均匀划分出了 n n n 个格子&#xff0c;格子编号从 1 1 1 到 n n n。每个格子上都染了一种颜色 c o l o r i color_i colori​ &#xff08;用 [ 1 &#xff0c; m ] [1&#xff0c;m] [1&#xff0c;m]当中的一个整数表…

DM Hw6

Hw6 聚类 1ab 2abcd 3abcde 456789 1 a b 一个点不来自某个特定簇的概率是 1 − 1 K 1-\frac{1}{K} 1−K1​ 对所有 2 K 2K 2K 个点都不来自该簇的概率是 ( 1 − 1 K ) 2 K (1-\frac{1}{K})^{2K} (1−K1​)2K 则 至少一个点来自该簇的概率为 1 − ( 1 − 1 K ) 2 K 1-(1-…

Jmeter环境安装(超级简单)

Jmeter的安装是非常简单的&#xff0c;只需要将下载的安装包解压后&#xff0c;就可以运行了&#xff01;&#xff01; 一、首先要下载Jmeter 1.1、官网下载&#xff1a; 下载最新版&#xff1a;https://jmeter.apache.org/download_jmeter.cgi https://jmeter.apache.org/…

第22讲:RBD块存储COW克隆解除父子镜像的依赖关系

RBD块存储COW克隆解除父子镜像的依赖关系 1.COW镜像克隆存在的依赖关系 在前面使用copy-on-write机制基于快照做出来的链接克隆&#xff0c;与快照依赖性很强&#xff0c;如果快照损坏或者丢失&#xff0c;那么克隆的镜像将无法使用&#xff0c;使用这个镜像创建的虚拟机也会…

什么是容器:从基础到进阶的全面介绍

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

深入分析 Android Activity (六)

文章目录 深入分析 Android Activity (六)1. Activity 的权限管理1.1 在 Manifest 文件中声明权限1.2 运行时请求权限1.3 处理权限请求结果1.4 处理权限的最佳实践 2. Activity 的数据传递2.1 使用 Intent 传递数据2.2 使用 Bundle 传递复杂数据 3. Activity 的动画和过渡效果3…

Windows Subsystem for Linux (WSL)查看在线发行版并在终端安装

在 Windows Subsystem for Linux (WSL) 中&#xff0c;你可以使用以下命令来查看在线可用的 Linux 发行版&#xff1a; 列出可用的 Linux 发行版&#xff1a; 使用以下命令查看可以通过在线商店获取的 Linux 发行版列表&#xff1a; wsl --list --online或者&#xff0c;你也可…

2024年上半年软件设计师试题及答案(回忆版)

目录 基础知识选择题案例题1.缺陷识别的数据流图2.球队、球员、比赛记录的数据库题3.用户、老师、学生、课程用例图4.算法题5.程序设计题 基础知识选择题 树的节点&#xff0c;度为4的有4个&#xff0c;度为3的有8个&#xff0c;度为2个有6个&#xff0c;度为1的有10个&#x…

1915springboot VUE 宠物寄养平台系统开发mysql数据库web结构java编程计算机网页源码maven项目

一、源码特点 springboot VUE 宠物寄养平台系统是一套完善的完整信息管理类型系统&#xff0c;结合springboot框架和VUE完成本系统&#xff0c;对理解JSP java编程开发语言有帮助系统采用springboot框架&#xff08;MVC模式开发&#xff09;&#xff0c;系统具有完整的源代码…

基于ERNIE Bot SDK开发智趣灯谜会游戏

项目背景 猜灯谜是中国传统节日元宵节中一种深受人们喜爱的民间游戏&#xff0c;它集趣味性、知识性和艺术性于一体&#xff0c;是中华文化的重要组成部分。猜灯谜&#xff0c;顾名思义&#xff0c;就是通过解读谜面来猜测谜底&#xff0c;谜底通常是各种物品、现象或概念。 猜…

STM32无源蜂鸣器播放音乐

开发板&#xff1a;野火霸天虎V2 单片机&#xff1a;STM32F407ZGT6 开发软件&#xff1a;MDKSTM32CubeMX 文章目录 前言一、找一篇音乐的简谱二、确定音调三、确定节拍四、使用STM32CubeMX生成初始化代码五、代码分析 前言 本实验使用的是低电平触发的无源蜂鸣器 无源蜂鸣器是…

微信小程序文本框输入显示已经输入的字数

我们遇到这样的需求&#xff0c;就是微信小程序的输入框下面需要显示输入的字数&#xff1a; 我们通常会使用bindinput事件&#xff0c;让显示的字数等于value的长度&#xff0c;看下面的图&#xff1a; 但在实践中&#xff0c;真机测试中&#xff0c;我们会发现以下问题: 这个…

C++笔记之Unix时间戳、UTC、TSN、系统时间戳、时区转换、local时间笔记

C++笔记之Unix时间戳、UTC、TSN、系统时间戳、时区转换、local时间笔记 ——2024-05-26 夜 code review! 参考博文 C++笔记之获取当前本地时间以及utc时间

深入分析 Android Activity (四)

文章目录 深入分析 Android Activity (四)1. Activity 的生命周期详解1.1 onCreate1.2 onStart1.3 onResume1.4 onPause1.5 onStop1.6 onDestroy1.7 onRestart 2. Activity 状态的保存与恢复2.1 保存状态2.2 恢复状态 3. Activity 的启动优化3.1 延迟初始化3.2 使用 ViewStub3.…