今年进入了个新公司,接手代码时遇到了比较蛋疼的事情,本地代码调试遇到了层层阻碍,无法一键简单启动就算了,我就忍了,一番操作终于启动起了了,启动又慢,启动了2~3分钟,后面调本地接口,还feign调用失败。出师未捷身先死啊,又没人整改下,好奇项目负责人也不改,他们是怎么进行调试和自测的,靠感觉和代码自信吗?
上图:
[2023-12-22 14:11:35.116]|WARN|main|||N/A|N/A|N/A|c.n.d.s.t.d.RetryableEurekaHttpClient#execute:130|Request execution failed with message: I/O error on GET request for "http://qz:123456@10.23.11.55:7000/eureka/apps/": Connect to 10.23.11.55:7000 [/10.23.11.55] failed: Operation timed out (Connection timed out); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to 10.23.11.55:7000 [/10.23.11.55] failed: Operation timed out (Connection timed out)
[2023-12-22 14:11:35.120]|WARN|main|||N/A|N/A|N/A|c.netflix.discovery.DiscoveryClient#get:304|Using default backup registry implementation which does not do anything.
日志中很明显写着连接eureka Connection timed out。
[2023-12-22 14:11:36.979]|WARN|pool-20-thread-1|||N/A|N/A|N/A|c.qz.common.config.CommonInitialize#lambda$run$0:57|[503] during [GET] to [http://qz-usercenter/getDataDictByType/message] [UserCenterFeign#getDataDictByType(String)]: [Load balancer does not contain an instance for the service qz-usercenter]
因为本地和eureka是网络隔离的,所以不存在eureka问题或者本地程序问题,只是网络问题而已,但是这个是无解的,所以放弃挣扎,需要曲线救国
很简单的目的,就是快速启动,顺利调试(OS:这不是个正常项目应该有的吗?)
-Deureka.client.register-with-eureka=false
-Dspring.autoconfigure.exclude=org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration,org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration
从140s->62s,提升54%的启动速度,1分钟启动还可以接受,后面看到主要花在连接数据库上,这个就不优化了,最主要是可以进行本地调用接口了。