奇怪的问题,再次启动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…

bouncycastle NoSuchFieldError:xxx 版本冲突

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

团队项目测评博客

第一部分 调研&#xff0c;评测 评测 安卓端评测 测试人&#xff1a;文垚描述最简单直观的个人第一次上手体验。第一次上手体验&#xff0c;操作简单&#xff0c;界面简洁。课程表与超级课程表差不多&#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…

.NETCore_生成实体

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

执行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…

php opcache 详解

PHP性能提升之OPcache相关参数详解 工具 memory 发布于December 15, 2016 标签: PHPOPcache 通过将 PHP 脚本预编译的字节码存储到共享内存中来提升 PHP 的性能&#xff0c; 存储预编译字节码的好处就是 省去了每次加载和解析 PHP 脚本的开销。 PHP 5.5.0 及后续版本中已经绑定…

es elasticsearch 几种常见查询场景 二次分组 java读取es的查询json文件

大家好&#xff0c;我是烤鸭&#xff1a; es中几种常见的查询场景,使用java读取es的json文件进行查询。 es 中文使用手册。https://www.elastic.co/guide/cn/elasticsearch/guide/current/foreword_id.html 1. 从最简单的查询开始 GET /_search {"hits" : {&qu…

阿里云服务器邮件发送

一个邮件发送的功能&#xff0c;本机调试无问题&#xff0c;但发布到阿里云服务器后邮件发送功能失败。 网上查了下大概是说阿里云把发送邮件的25端口禁用掉了 那么解决方式一就是向阿里云申请开放25端口&#xff0c;但具体如何申请&#xff0c;并未深入操作。 解决方式二&…

全链路追踪竟然如此简单? bytebuddy搭建全链路追踪的demo 附代码

大家好&#xff0c;我是烤鸭&#xff1a; 最近一直在研究全链路追踪&#xff0c;比如cat、skywalking、zipkin等。 发现 skywalking 是基于bytebuddy 实现的&#xff0c;想自己试着写一下demo。 demo的git地址,感兴趣的可以自己试下。代码在idea中可以跑,至于其他场…

echarts地图的基本使用配置

一、空气质量图 代码和配置如下&#xff1a; <template><div class"box"><div id"map"></div></div> </template><script>import china from echarts/map/js/china.js export default {data(){return {}},mount…

从源码角度分析下 micrometer 自定义 metrics endpoint 和 springboot actuator

大家好&#xff0c;我是烤鸭&#xff1a; 今天分享下 micrometer 的源码&#xff0c;和springboot集成 自定义endpoint 的使用。 1. 文档信息 官方文档&#xff1a; http://micrometer.io/docs github&#xff1a; https://github.com/micrometer-metrics/micrometer s…

云打码

1、云打码平台注册开发者模式用户登录 2、建立项目&#xff0c;下载项目案列代码接口 代码如下&#xff1a; 1 import http.client, mimetypes, urllib, json, time, requests2 3 ######################################################################4 5 class YDMHttp:6 …

Perhaps you are running on a JRE rather than a JDK? 关于 idea maven 缓存的问题 清理 idea maven 缓存

大家好&#xff0c;我是烤鸭&#xff1a; 1. 先检查是否环境变量的问题 参考这篇 https://blog.csdn.net/mingjie1212/article/details/106963143 2. 如果确定环境变量没问题 执行maven install的时候报错&#xff0c;Perhaps you are running on a JRE rather than a JDK …

swift - 使用系统app导航

import UIKit//1.导入框架 import MapKitclass ViewController: UIViewController {lazy var geoCoder : CLGeocoder {return CLGeocoder()}()override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {geoCoder.geocodeAddressString("广州&…

springcloud gateway 使用nacos 作为配置中心 和 注册中心

大家好&#xff0c;我是烤鸭&#xff1a; 今天分享下 springcloud gateway 使用nacos作为配置中心和注册中心&#xff0c;主要是还是配置中心。 源码下载&#xff1a; https://gitee.com/fireduck_admin/springcloud-gateway-nacos-demo 1. 本地部署nacos 下载 https://g…

springboot 拦截器的坑 WebMvcConfigurationSupport 失效

大家好&#xff0c;我是烤鸭&#xff1a; 今天遇到一个拦截器失效的问题&#xff0c;具体看源码分析下。 环境: springboot 2.x spring 5.x 1. 先说下业务场景 需求是对请求进入时和离开时对和线程id绑定&#xff0c;用的Threadlocal&#xff0c;现在有一个问题&#xff0…

skywalking 源码解析——多线程变量传递 EnhancedInstance

大家好&#xff0c;我是烤鸭&#xff1a; 今天分享下 skywalking源码&#xff0c;正好自己用到相关的内容了。 1. 拦截点 三个主要的拦截器、构造方法、静态方法和示例方法&#xff0c;每个切面里都可以重写这些方法&#xff0c;并且指定进入的拦截器。 2. trace 相关内容 …

2018-2019-1 20165303 实验五 通讯协议设计

任务一 Linux下OpenSSL的安装与使用 前往OpenSSL官网&#xff0c;选择打开OpenSSL源码下载地址&#xff0c;按照下图所示方法下载压缩包“openssl-master.zip Linux下使用unzip openssl-master.zip命令解压 安装的具体命令如下&#xff1a;$ ./config$ make$ make test$ make i…