最近突然遇到一个问题,本地PC上的服务起不来。从日志看,没有任何报错,但是就是没初始化完成
最后的日志是这样:
WARN c.b.m.c.t.support.ReflectLambdaMeta - Unable to make field private final java.lang.Class java.lang.invoke.SerializedLambda.capturingClass accessible: module java.base does not "opens java.lang.invoke" to unnamed module @53ca01a2
"con"2024-11-27 10:33:40 - [main] WARN c.r.c.TrustEverythingTrustManager - SECURITY ALERT: this trust manager trusts every certificate, effectively disabling peer verification. This is convenient for local development but offers no protection against man-in-the-middle attacks. Please see https://www.rabbitmq.com/ssl.html to learn more about peer certificate verification.
最后的日志也没有什么用,这不会导致起不来
打开debug日志,还是没看到啥有用的日志
debug spring的源码,走到DefaultListableBeanFactory的preInstantiateSingletons
发现走到这个阶段就没出来 Trigger initialization of all non-lazy singleton beans
这说明是在初始化某个singleton bean的时候卡住了没出来
最后拿出arthas,直接打印main线程的堆栈,看到:
发现是这里在调httpclient发请求,然后卡住了,原来他这个http请求没设置超时时间,导致一直阻塞
这个问题说明,bean初始化中尽量不要调http接口,如果要,也一定注意设置超时时间,比如启动阻塞