奇怪的问题,再次启动jar包会导致bean对象失效?Unknown redis exception Cannot connect, Event executor group is terminated

大家好,我是烤鸭:

    踩坑实录。一个某次上线导致的问题,并没有改过什么代码,只是重新上了一次包,没上之前从来没出过这个问题。最开始日志的报错信息一直是 NoClassDefFoundError could not initialize class ,发现是 static 初始化 spring bean 失败,导致类没有加载成功。

1.  报错日志

ex.ToString().org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.etc.common.utils.SequenceKit 
ex.Message,Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.etc.common.utils.SequenceKit 
ex.StackTrace,org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1006) 
ex.Source,java.lang.NoClassDefFoundError: Could not initialize class com.etc.common.utils.SequenceKit 

2.  代码复现:

SequenceKit.java

package com.xxx.common.utils;import java.util.concurrent.atomic.AtomicInteger;import org.checkerframework.common.value.qual.StaticallyExecutable;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;import com.fasterxml.jackson.core.Versioned;public class SequenceKit {private static final Logger logger = LoggerFactory.getLogger(SequenceKit.class);public static final String TYPE_INCR = "INCR:";public static final RedisTemplate redisTemplate = SpringContextUtil.getBean("redisTemplate", RedisTemplate.class);/*** 根据指定业务前缀生成自增 number* @return*/public static String getBusinessSequenceDoc(String key) {String date = new DateTime().toString("yyyyMMddHHmmss");logger.info("redisTemplate{}"+redisTemplate);Long no = redisTemplate.opsForValue().increment(TYPE_INCR+key, 1);if(no == null ){logger.info("redis 连接失败{}"+TYPE_INCR+key);String uuid = UUIDUtil.generate();return  key+ "-" + date + "-" + uuid;}return  key+ "-" + date + "-" + String.format("%06d", no);}}
SpringContextUtil.java
package com.xxx.common.utils;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;/*** * @ClassName: SpringContextUtil* @Description: 静态获取Bean* @author gaogang* @date 2016年7月12日 下午4:21:26**/
@Component
public class SpringContextUtil implements ApplicationContextAware {/** 当前IOC上下文环境*/private static ApplicationContext applicationContext; /** 设置当前上下文环境,此方法由spring自动装配 (non-Javadoc)* * @see* org.springframework.context.ApplicationContextAware#setApplicationContext* (org.springframework.context.ApplicationContext)*/@Overridepublic void setApplicationContext(ApplicationContext applicationContext)throws BeansException {SpringContextUtil.applicationContext = applicationContext;}public static ApplicationContext getApplicationContext() {return applicationContext;}/*** * @Description 从spring容器获取bean实例</br>*  <font color='red'>注意,这里beanId是spring ioc中bean实例的名字,如果是注解扫描方式,没有特意指定名称,一般为类名,首字母小写(java遵从驼峰命名规则),如果有指定名称,则为指定的bean名称</font>* @param name  lmk name,infact it's name in spring IOC* @return  bean实例** @author wjggwm* @data 2016年8月25日 下午2:22:16*/public static Object getBean(String name) throws BeansException {return getApplicationContext().getBean(name);}/*** * @Description 从spring容器获取bean实例</br>*  <font color='red'>注意,这里beanId是spring ioc中bean实例的名字,如果是注解扫描方式,没有特意指定名称,一般为类名,首字母小写(java遵从驼峰命名规则),如果有指定名称,则为指定的bean名称</font>* @param name  lmk name,infact it's name in spring IOC* @param requiredType  lmk class类型* @return  bean实例* @throws BeansException** @author wjggwm* @data 2017年1月5日 下午5:58:27*/public static <T> T getBean(String name, Class<T> requiredType) throws BeansException {return getApplicationContext().getBean(name, requiredType);}public static <T> T getBean(Class<T> requiredType) {return applicationContext.getBean(requiredType);}}

3.  问题猜想

静态变量初始化在springbean之前,导致获取不到bean对象,报错。

其实有点想不通,测试环境和线上已经运行那么多天,如果是这个问题,早就应该曝光了。

静态变量的初始化是在调用的时候再赋值,也就是调用这个方法的 getBean的时候,项目早已经启动成功,不存在拿不到bean的情况。

4.  场景模拟

后来想模拟线上的场景,将静态变量 = 一个抛异常的方法,类似下面。确实爆错了,原因找到了,就是这个对象初始化失败。

为了避免这个问题,做了一下修改:

5.  根本原因分析

改完就不会报异常了么。如果场景一样的话,还是会报的。再贴一段同时报错信息的日志。是redis 相关的日志,好像有点意思,都是redis相关的。

2020-05-20 15:38:54.356 [TID:591.16551.15899603343206723] [DubboServerHandler-20.0.22.51:20886-thread-105]  INFO  [class:co
m.etc.redis.RedisUtil | method:set | line:177] logInfo==> redis set 异常
org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.IllegalStateException: Cannot connect, Event executor group is termin
ated.at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:53)at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:43)at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:257)at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:718)at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.setEx(LettuceStringCommands.java:227)at org.springframework.data.redis.connection.DefaultedRedisConnection.setEx(DefaultedRedisConnection.java:252)at org.springframework.data.redis.core.DefaultValueOperations$4.potentiallyUsePsetEx(DefaultValueOperations.java:230)at org.springframework.data.redis.core.DefaultValueOperations$4.doInRedis(DefaultValueOperations.java:223)at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)at org.springframework.data.redis.core.DefaultValueOperations.set(DefaultValueOperations.java:218)at com.etc.redis.RedisUtil.set(RedisUtil.java:170)at com.etc.service.credit.EtcCreditApplyRelationServiceImpl.createNewApplyOrder(EtcCreditApplyRelationServiceImpl.java:1089)at com.etc.service.credit.EtcCreditApplyRelationServiceImpl$$FastClassBySpringCGLIB$$d7d53003.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)at com.etc.service.credit.EtcCreditApplyRelationServiceImpl$$EnhancerBySpringCGLIB$$a874bba6.createNewApplyOrder(<generated>)at com.alibaba.dubbo.common.bytecode.Wrapper33.invokeMethod(Wrapper33.java)at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:47)at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:76)at com.alibaba.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:52)at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56)at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:62)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke$original$Mxc753iz(MonitorFilter.java:75)at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke$original$Mxc753iz$accessor$LYrs6xRu(MonitorFilter.java)at com.alibaba.dubbo.monitor.support.MonitorFilter$auxiliary$Xy5iiuam.call(Unknown Source)at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:93)at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:72)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:131)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:72)at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:103)at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:96)at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:172)at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:80)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Cannot connect, Event executor group is terminated.at io.lettuce.core.AbstractRedisClient.initializeChannelAsync(AbstractRedisClient.java:254)at io.lettuce.core.cluster.RedisClusterClient.connectStatefulAsync(RedisClusterClient.java:658)at io.lettuce.core.cluster.RedisClusterClient.connectStateful(RedisClusterClient.java:635)at io.lettuce.core.cluster.RedisClusterClient.connectClusterImpl(RedisClusterClient.java:530)at io.lettuce.core.cluster.RedisClusterClient.connect(RedisClusterClient.java:339)at org.springframework.data.redis.connection.lettuce.ClusterConnectionProvider.getConnection(ClusterConnectionProvider.java:55)at org.springframework.data.redis.connection.lettuce.LettuceConnection.doGetAsyncDedicatedConnection(LettuceConnection.java:962)at org.springframework.data.redis.connection.lettuce.LettuceConnection.getDedicatedConnection(LettuceConnection.java:942)at org.springframework.data.redis.connection.lettuce.LettuceConnection.getConnection(LettuceConnection.java:903)at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.getConnection(LettuceStringCommands.java:714)at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.setEx(LettuceStringCommands.java:225)... 53 common frames omitted

我们顺着报错类找到源码看一下。

 protected <K, V, T extends RedisChannelHandler<K, V>> ConnectionFuture<T> initializeChannelAsync(ConnectionBuilder connectionBuilder) {SocketAddress redisAddress = connectionBuilder.socketAddress();if (clientResources.eventExecutorGroup().isShuttingDown()) {throw new IllegalStateException("Cannot connect, Event executor group is terminated.");}//
}

我们看一下  eventExecutorGroup 的说明。内部操作的线程池。

 /*** Returns the computation pool used for internal operations. Such tasks are periodic Redis Cluster and Redis Sentinel* topology updates and scheduling of connection reconnection by {@link io.lettuce.core.protocol.ConnectionWatchdog}.** @return the computation pool used for internal operations*/EventExecutorGroup eventExecutorGroup();

这个判断 就是线程池对应的group是不是关闭了。那我们就看一下哪个地方调用了shutdown方法。有点多,先看默认的Default哪个吧。

一路找下去:

DefaultClientResources.shutdown() ——> AbstractRedisClient.shutdownAsync() ——>LettuceConnectionFactory.destroy()

最终找到了 LettuceConnectionFactory 实现了 DisposableBean.destroy()

看下 DisposableBean 的说明:由要在销毁时释放资源的bean实现的接口。将在单个销毁对象时调用destroy方法。也支持在应用程序生命周期的驱动下,在关机时处理所有单例。

/** Copyright 2002-2018 the original author or authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**      http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package org.springframework.beans.factory;/*** Interface to be implemented by beans that want to release resources on destruction.* A {@link BeanFactory} will invoke the destroy method on individual destruction of a* scoped bean. An {@link org.springframework.context.ApplicationContext} is supposed* to dispose all of its singletons on shutdown, driven by the application lifecycle.** <p>A Spring-managed bean may also implement Java's {@link AutoCloseable} interface* for the same purpose. An alternative to implementing an interface is specifying a* custom destroy method, for example in an XML bean definition. For a list of all* bean lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.** @author Juergen Hoeller* @since 12.08.2003* @see InitializingBean* @see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName()* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#destroySingletons()* @see org.springframework.context.ConfigurableApplicationContext#close()*/
public interface DisposableBean {/*** Invoked by the containing {@code BeanFactory} on destruction of a bean.* @throws Exception in case of shutdown errors. Exceptions will get logged* but not rethrown to allow other beans to release their resources as well.*/void destroy() throws Exception;}

这只是一种猜想,redisTemplate 这个 bean被销毁了(在项目shutdown的过程中)。

6.  再翻日志

再往前翻翻日志,发现启动了项目的时候,前一次的项目并没有停掉,导致新上线的启动失败。

这也怪我,运维说启动成功了,我看日志一直在刷,并没有意识到这个问题。

2020-05-20 15:36:34.443 [TID:N/A] [main-EventThread]  INFO  [class:org.apache.curator.framework.state.ConnectionStateManage
r | method:postState | line:237] logInfo==> State change: CONNECTED
2020-05-20 15:36:53.004 [TID:N/A] [main]  INFO  [class:io.netty.util.internal.logging.Slf4JLogger | method:info | line:101]logInfo==> Starting without optional epoll library
2020-05-20 15:36:53.007 [TID:N/A] [main]  INFO  [class:io.netty.util.internal.logging.Slf4JLogger | method:info | line:101]logInfo==> Starting without optional kqueue library
2020-05-20 15:36:53.361 [TID:N/A] [main]  INFO  [class:com.etc.service.xxx.WeimobServiceImpl | method:refreshAccessToken| line:234] logInfo==> 启动刷新任务,开始执行时间:2020-05-20T16:39:16.724
2020-05-20 15:36:53.961 [TID:N/A] [main]  INFO  [class:com.etc.config.BeforeStartup | method:onApplicationEvent | line:33]logInfo==> onApplicationEvent!!!redisUtil=com.etc.redis.RedisUtil@4407b042
2020-05-20 15:36:54.910 [TID:N/A] [main]  INFO  [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] 
logInfo==> Starting ProtocolHandler ["http-nio-8096"]
2020-05-20 15:36:54.916 [TID:N/A] [main]  ERROR [class:org.apache.juli.logging.DirectJDKLog | method:log | line:182] 
logInfo==> Failed to start connector [Connector[HTTP/1.1-8096]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8096]]at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225)at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:256)at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:198)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:300)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265)at com.etc.ApplyServiceApplication.main(ApplyServiceApplication.java:33)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.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failedat org.apache.catalina.connector.Connector.startInternal(Connector.java:1020)at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)... 21 common frames omitted
Caused by: java.net.BindException: Address already in useat sun.nio.ch.Net.bind0(Native Method)at sun.nio.ch.Net.bind(Net.java:433)at sun.nio.ch.Net.bind(Net.java:425)at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:219)at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1151)at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591)at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018)... 22 common frames omitted
2020-05-20 15:36:54.921 [TID:N/A] [main]  INFO  [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] 
logInfo==> Pausing ProtocolHandler ["http-nio-8096"]
2020-05-20 15:36:54.922 [TID:N/A] [main]  INFO  [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] 
logInfo==> Stopping service [Tomcat]
2020-05-20 15:36:54.961 [TID:N/A] [main]  INFO  [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] 
logInfo==> The stop() method was called on component [StandardServer[-1]] after stop() had already been called. The second call will be ignored.
2020-05-20 15:36:54.962 [TID:N/A] [main]  INFO  [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] 
logInfo==> Stopping ProtocolHandler ["http-nio-8096"]
2020-05-20 15:36:54.962 [TID:N/A] [main]  INFO  [class:org.apache.juli.logging.DirectJDKLog | method:log | line:180] 
logInfo==> Destroying ProtocolHandler ["http-nio-8096"]

这些都是小问题,但是注意到日志里多了一行,有点麻烦的。停止方法被已经被调用了,这次就忽略了。

The stop() method was called on component [StandardServer[-1]] after stop() had already been called. The second call will be ignored。

是运维的停止脚本(kill pid) 导致触发了第一次的stop方法么。如果这样就说的通了,stop的时候,导致调用了 shutdown ,将 redisTemplate 从 工厂移除,从而静态初始化失败。这个也有一个问题,就是为什么 继承 DisposableBean 那么多类,怎么就单独移除了一个 RedistTemplate。

只能强行解释一波了,项目由于某些原因没有停下来(可能是有在执行任务的线程),但是部分类已经触发了 destory 方法,从而导致部分连接池、bean对象失效等问题。

7.  解决方案

运维操作的时候,最好盯着日志,是不是真的停止和启动了。

 

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

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

相关文章

从Spring到SpringBoot构建WEB MVC核心配置详解

目录 理解Spring WEB MVC架构的演变认识Spring WEB MVC传统时代的Spring WEB MVC新时代Spring WEB MVCSpringBoot简化WEB MVC开发自动装配条件装配外部化配置本章源码下载理解Spring WEB MVC架构的演变 基础Servlet架构核心架构&#xff1a;前端控制器Spring WEB MVC架构认识Sp…

[css] 说说你对!important的理解,一般在哪些场景使用?

[css] 说说你对!important的理解&#xff0c;一般在哪些场景使用&#xff1f; !important 可以让样式的特指度最高&#xff0c;覆盖任何样式&#xff0c;而且本身不可被覆盖。 一般场景就是用来强制覆盖其他样式&#xff0c;用的比较少&#xff0c;不建议使用&#xff0c;因为…

bouncycastle NoSuchFieldError:xxx 版本冲突

大家好&#xff0c;我是烤鸭&#xff1a; bouncycastle NoSuchFieldError:xxx 就是版本冲突了。 这里提示下&#xff0c;冲突有可能不止在项目里&#xff0c;也有可能在jre的lib目录下... 总之就是classpath加载了同样的jar包(不同版本)。如图所示&#xff1a; 项目…

团队项目测评博客

第一部分 调研&#xff0c;评测 评测 安卓端评测 测试人&#xff1a;文垚描述最简单直观的个人第一次上手体验。第一次上手体验&#xff0c;操作简单&#xff0c;界面简洁。课程表与超级课程表差不多&#xff0c;不同课程不同颜色显示&#xff0c;简洁明了。但是整体界面在简洁…

[css] 在实际编写css中你有遇到过哪些浏览器兼容性的问题?怎么解决的?

[css] 在实际编写css中你有遇到过哪些浏览器兼容性的问题&#xff1f;怎么解决的&#xff1f; 必用的三个工具PostCSSAutoprefixerBrowserslist个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录…

springboot 整合 kafka demo 顺便看一下源码

大家好&#xff0c;我是烤鸭: 今天分享下 springboot 整合 kafka。 1. 环境参数: windows kafka_2.11-2.3.0 zookeeper-3.5.6 springboot 2.3.0 2. 下载安装zookeeper kafka zookeeper: https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.5.8/apache-zooke…

2018ACM/ICPC亚洲区域赛(焦作)F. Honeycomb

目录 F. Honeycomb (2018-ACM/ICPC焦作)F. Honeycomb (2018-ACM/ICPC焦作) Problem F. Honeycomb Input file: standard input Output file: standard output A honeycomb is a mass wax cells built by honey bees, which can be described as a regular tiling of the Euclid…

[css]怎么改变选中文本的文字颜色和背景色?

[css]怎么改变选中文本的文字颜色和背景色&#xff1f; ::selection { background-color: #222; color: white; }个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关前端面试题

goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.6:generate failed: Index: 0, Size: 0

大家好&#xff0c;我是烤鸭&#xff1a; 报错信息如下&#xff1a; Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.6:generate (default-cli) on project etc-bosc-repository: Execution default-cli of goal org.mybatis.generator:m…

.NETCore_生成实体

先安装以下三个包&#xff0c;或者使用Nuget引用 不要问我为什么&#xff0c;按哥说的做吧&#xff1a; Install-Package Microsoft.EntityFrameworkCore.SqlServer Install-Package Microsoft.EntityFrameworkCore.Tools Install-Package Microsoft.VisualStudio.Web.CodeGene…

[css] 你对响应式设计的理解是什么?知道它基本的原理是吗?要想兼容低版本的IE怎么做呢?

[css] 你对响应式设计的理解是什么&#xff1f;知道它基本的原理是吗&#xff1f;要想兼容低版本的IE怎么做呢&#xff1f; 理解&#xff1a;在不同系统&#xff0c;不同设备&#xff0c;不同尺寸的界面&#xff0c;有良好的用户体验&#xff0c;舒适的阅读体验&#xff0c;交…

php rabbitmq demo

composer安装php rabbitmq包 新建composer.json文件&#xff0c;composer install 安装 {"require": {"php-amqplib/php-amqplib": ">2.6.1"} } 创建config.php文件 <?php return [vendor > [path > ./vendor],rabbitmq > [host…

[css] 你有使用过哪些栅格系统?都有什么区别呢?

[css] 你有使用过哪些栅格系统&#xff1f;都有什么区别呢&#xff1f; bootstrap3 float完成的栅格 bootstrap4 flex完成的栅格个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通…

dubbo源码解析(二)

大家好&#xff0c;我是烤鸭&#xff1a; dubbo 源码解析&#xff1a; 1.服务导出 介绍: Dubbo 服务导出过程始于 Spring 容器发布刷新事件&#xff0c;Dubbo 在接收到事件后&#xff0c;会立即执行服务导出逻辑。整个逻辑大致可分为三个部分&#xff0c;第一部分是前置工作&am…

[css] 请说说*{box-sizing: border-box;}的作用及好处有哪些?

[css] 请说说*{box-sizing: border-box;}的作用及好处有哪些&#xff1f; 还是喜欢用默认的content-box 不考虑老版ie 比较通配符的性能较差 第三方的UI库的盒模型也都是标准盒模型个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持…

执行mongod其他实例出现的问题

windows环境下&#xff0c;配置其他mongo实例&#xff0c;会出现一些问题 1、配置路径不对&#xff0c;执行bat文件时出现闪屏 根据提示创建C:\data\db\ 目录&#xff08;因为mongodb默认在/data/db下创建数据库&#xff09;&#xff0c;重新执行mongod实例&#xff0c;就OK&am…

从 class 文件 看 synchronize 锁膨胀过程(偏向锁 轻量级锁 自旋锁 重量级锁)

大家好&#xff0c;我是烤鸭: 前几天看马士兵老师的并发的课&#xff0c;里边讲到了 synchronize 锁的膨胀过程&#xff0c;今天想用代码演示一下。 1. 简单介绍 关于synchronize jdk 1.5 以后的优化&#xff0c;由重量级锁调整为膨胀过程。分别是 偏向锁 轻量级锁&#xff0…

[css] 说说你对jpg、png、gif的理解,分别在什么场景下使用?有使用过webp吗?

[css] 说说你对jpg、png、gif的理解&#xff0c;分别在什么场景下使用&#xff1f;有使用过webp吗&#xff1f; jpg, 色彩复杂图片 png, 色彩简单图片 gif, 动图, 或者色彩极简的icon等 webp, 判断能使用webp的浏览器就是用webp个人简介 我是歌谣&#xff0c;欢迎和大家一起交…

GC算法与收集器

一.判断对象是否存活 1.引用计数算法 2.可达性分析算法 二.垃圾收集算法 1.标记-清除算法&#xff1a;效率低&#xff0c;内存碎片 2.复制算法&#xff1a;适用于对象存活率低 3.标记-整理算法&#xff1a;没有内存碎片 4.分代收集算法&#xff1a;新生代用复制算法 老年代用标…

[css] 如何消除transition闪屏?

[css] 如何消除transition闪屏&#xff1f; 题目越简单越有含量。 看题意不知道在问什么&#xff0c;说明这个问题自己没注意或不熟悉&#xff0c;而不是去怀疑题目出的有问题。这个问题自己没有遇到过&#xff0c;或者说没有注意过这个问题&#xff0c;网上搜索了下答案&…