consul+zuul 总是转发到不健康节点

****图片说明

consul agent -dev 模式下
图片说明

搭建了 几个微服务,注册到consul (V1.4.3)上
现在几个微服务重启后,在consul的健康页面上查看几个微服务状态很奇怪
使用zuul进行转发访问都是找不到service-id
通过请求
http://localhost:19003/actuator/health
查看,服务状态都是down的,想问下是怎么回事?
图片说明

注:第一次从头再来,都是正常up的,只要一重启某个服务,就某个服务异常了。

下面为配置:

admin-service

图片说明

gateway-service

图片说明

请求:localhost:19002/admin/getTest

图片说明****

1个回答

不是大问题,再仔细找找,看看问题出在哪。

fuckme123
哪来那么多昵称 是缺了什么配置吗?还是配置错了。。。
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
consul+zuul 总是转发到不健康节点

****![图片说明](https://img-ask.csdn.net/upload/201903/16/1552726608_932541.png) consul agent -dev 模式下 ![图片说明](https://img-ask.csdn.net/upload/201903/16/1552728412_755468.png) 搭建了 几个微服务,注册到consul (V1.4.3)上 现在几个微服务重启后,在consul的健康页面上查看几个微服务状态很奇怪 使用zuul进行转发访问都是找不到service-id 通过请求 http://localhost:19003/actuator/health 查看,服务状态都是down的,想问下是怎么回事? ![图片说明](https://img-ask.csdn.net/upload/201903/16/1552727091_724995.png) 注:第一次从头再来,都是正常up的,只要一重启某个服务,就某个服务异常了。 下面为配置: ## admin-service ![图片说明](https://img-ask.csdn.net/upload/201903/16/1552727061_731723.png) ## gateway-service ![图片说明](https://img-ask.csdn.net/upload/201903/16/1552727072_807091.png) 请求:localhost:19002/admin/getTest ![图片说明](https://img-ask.csdn.net/upload/201903/16/1552727274_971412.png)****

spring cloud spring boot 中使用zuul+consul, zuul路由不到配置了context-path的服务

spring cloud spring boot 中使用zuul+consul, zuul路由不到配置了context-path的客户端,不配置context-path可以路由。 网关配置: ![图片说明](https://img-ask.csdn.net/upload/201908/12/1565579622_88622.jpg) 被调用服务配置: ![图片说明](https://img-ask.csdn.net/upload/201908/12/1565579556_555688.jpg) 网关调用报错:![图片说明](https://img-ask.csdn.net/upload/201908/12/1565579883_859782.jpg)

API网关报错负载均衡器不能找到客户端的服务器?Consul+zuul

直接上错误信息:其中svms-file-8585时我的另一个服务id ``` Registering service with consul: NewService{id='svms-file-8585', name='svms-file', tags=[serverType=2, secure=false], address='172.16.128.95', meta=null, port=8585, enableTagOverride=null, check=Check{script='null', interval='10s', ttl='null', http='http://172.16.128.95:8585/health', method='null', header={}, tcp='null', timeout='null', deregisterCriticalServiceAfter='null', tlsSkipVerify=null, status='null'}, checks=null} ``` ------------------------------------------------------------ ``` com.netflix.zuul.exception.ZuulException: Forwarding error at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:198) ~[spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:173) ~[spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:119) ~[spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:117) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:193) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:118) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:116) ~[zuul-core-1.3.1.jar:1.3.1] at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81) ~[zuul-core-1.3.1.jar:1.3.1] at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:165) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequest(ZuulController.java:45) [spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) [spring-webmvc-5.1.5.RELEASE.jar:5.1.5.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) [spring-boot-actuator-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117) [spring-boot-actuator-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106) [spring-boot-actuator-2.1.3.RELEASE.jar:2.1.3.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) [tomcat-embed-core-9.0.16.jar:9.0.16] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.16.jar:9.0.16] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_161] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.16.jar:9.0.16] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161] Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: svms-file-8585 at com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0] at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:184) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0] at com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:180) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber$1.call(OperatorRetryWithPredicate.java:127) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(TrampolineScheduler.java:73) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.schedule(TrampolineScheduler.java:52) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:79) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OperatorRetryWithPredicate$SourceSubscriber.onNext(OperatorRetryWithPredicate.java:45) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:276) ~[rxjava-1.3.8.jar:1.3.8] at rx.Subscriber.setProducer(Subscriber.java:209) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:138) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.util.ScalarSynchronousObservable$JustOnSubscribe.call(ScalarSynchronousObservable.java:129) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.subscribe(Observable.java:10423) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.subscribe(Observable.java:10390) ~[rxjava-1.3.8.jar:1.3.8] at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:443) ~[rxjava-1.3.8.jar:1.3.8] at rx.observables.BlockingObservable.single(BlockingObservable.java:340) ~[rxjava-1.3.8.jar:1.3.8] at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:112) ~[ribbon-loadbalancer-2.3.0.jar:2.3.0] at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:221) ~[spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.netflix.zuul.filters.route.support.AbstractRibbonCommand.run(AbstractRibbonCommand.java:55) ~[spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) ~[hystrix-core-1.5.18.jar:1.5.18] at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) ~[hystrix-core-1.5.18.jar:1.5.18] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.subscribe(Observable.java:10423) ~[rxjava-1.3.8.jar:1.3.8] at rx.Observable.subscribe(Observable.java:10390) ~[rxjava-1.3.8.jar:1.3.8] at rx.internal.operators.BlockingOperatorToFuture.toFuture(BlockingOperatorToFuture.java:51) ~[rxjava-1.3.8.jar:1.3.8] at rx.observables.BlockingObservable.toFuture(BlockingObservable.java:410) ~[rxjava-1.3.8.jar:1.3.8] at com.netflix.hystrix.HystrixCommand.queue(HystrixCommand.java:378) ~[hystrix-core-1.5.18.jar:1.5.18] at com.netflix.hystrix.HystrixCommand.execute(HystrixCommand.java:344) ~[hystrix-core-1.5.18.jar:1.5.18] at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:167) ~[spring-cloud-netflix-zuul-2.1.1.RELEASE.jar:2.1.1.RELEASE] ... 64 common frames omitted ```

Spring Cloud zuul问题:在使用中遇到了一个关于用户信息传递的问题

系统环境: web项目使用单点登录 通过zuul转发到请求到指定的服务端(zuul和服务端不做单点登录) 现在想要把当前登录的用户名传递到后端服务器,但是在zuul上通过过滤器设置 @Override public Object run() { RequestContext ctx = RequestContext.getCurrentContext(); HttpServletRequest request = ctx.getRequest(); request.setAttribute("username", request.getRemoteUser()); logger.info("登陆用户"+request.getRemoteUser()); logger.info("send {} request to {}",request.getMethod(),request.getRequestURL().toString()); return null; } 在zuul的过滤器中能获取到,但是在服务端并不能获取 求教要通过什么办法把参数传递到zuul之后的服务器

springcloud获取不到consul刷新后个配置

在本地启动了1个 Consul。consul agent -dev 添加了配置 ``` spring: application: name: spring-cloud-consul-ok cloud: consul: host: 127.0.0.1 port: 8500 discovery: enabled: true register: true healthCheckInterval: 15s health-check-timeout: 1s instance-id: ${spring.application.name}-${spring.cloud.consul.host}-${spring.cloud.consul.port} serviecName: ${spring.application.name} config: enabled: true format: YAML data-key: configuration ``` 属性配置类: ``` @Configuration @ConfigurationProperties("sample") @Data @RefreshScope public class SampleProperties { private String prop = "default data"; } ``` 引用方式: ``` @SpringBootApplication @EnableDiscoveryClient @EnableHystrix @RestController @EnableConfigurationProperties @EnableFeignClients @Slf4j public class ConsulAreYouOkApplication { @Autowired private RibbonHelloService ribbonHelloService; @Autowired private SampleProperties sampleProperties; @RequestMapping(value = "/hello", method = RequestMethod.GET) public String areyouok(@RequestParam String name) { return ribbonHelloService.sayHi(name)+" "+sampleProperties.getProp(); } ``` 看着没什么错,但是一直 拿不到 Consul上面的配置,从日志里面 也可以看到Spring已经检测到了 属性的变化,但是就是一直获取不到新值。 版本如下 spring-boot-dependencies 1.5.10.RELEASE spring-cloud-consul-config 1.3.2.RELEASE spring-cloud-starter-consul-discovery 1.3.2.RELEASE

请教一个Consul的问题,代码见图,服务注册是可以成功的,不知道为什么解除注册报了连接错误

请教一个Consul的问题,代码见图,服务注册是可以成功的,不知道为什么解除注册报了连接错误 ConsulClient consulClient = new ConsulClient(nodeHostAdress); Iterator<Map.Entry<String, Service>> it_service = consulClient.getAgentServices().getValue().entrySet().iterator(); java.net.ConnectException: Connection refused (Connection refused) ![图片说明](https://img-ask.csdn.net/upload/201809/18/1537241871_608581.png)

使用spring-cloud-netflix-zuul-websocket出现问题,zuul和webSocket

直接访问可以,通过zuul网关代理不可以 ![图片说明](https://img-ask.csdn.net/upload/201812/03/1543825105_772398.png)

ribbon是负载均衡,zuul也可以做到负载均衡,在消费者里面 通过zuul对应url去调服务效果一样吗

ribbon是负载均衡,zuul也可以做到负载均衡,在消费者里面 通过zuul对应url去调服务效果一样吗

spring boot 2.1.1.RELEASE 不支持consul

最近使用consul作为spring cloud的服务发现,一直不能把服务注册到consul上,发生spring boot使用的是2.1.1.RELEASE版本,后来改成2.0.3.RELEASE能够注册成功。 spring cloud使用Finchley.RELEASE或者Finchley.SR2没有影响。 分别使用consul1.2.1,1.3.1,1.4测试了,结果一样。 哪位同学知道为什么?

consul不同环境配置的问题

如果dev环境consul的配置如下 ``` spring: cloud: consul: host: localhost port: 8500 discovery: hostname: ${spring.cloud.client.ip-address} healthCheckPath: /actuator/health healthCheckInterval: 15s #默认是10s 可设置ps:15s or 1m ip-address: true instanceId: ${spring.application.name}:${spring.cloud.client.ipaddress}:${server.port} tags: ${spring.profiles.active} config: prefix: config enabled: true #默认是true -- format: YAML # 表示consul上面文件的格式 有四种 YAML PROPERTIES KEY-VALUE FILES defaultContext: demo-server # 表示配置文件对应的应用名称 data-key: data #表示consul上面的KEY值(或者说文件的名字) 默认是data profileSeparator: '-' ``` 那么请问在pre环境下。(服务器地址120.78.8.111) cunsul的配置,尤其是host应该怎么配?

以编程方式启动的Consul代理无法打开HTTP端口

<div class="post-text" itemprop="text"> <p>I try to start a Consul agent using their Golang <a href="http://github.com/hashicorp/consul/command/agent" rel="nofollow">package</a>. The server itself comes up but I can't interact with it because it does not start to listen for incoming HTTP requests.</p> <p>My code to start the agent:</p> <pre><code>//create the logwriter writer := bytes.NewBuffer(server.log) agentConfig := agent.DefaultConfig() agentConfig.BindAddr = "127.0.0.1" agentConfig.DevMode = true agentConfig.Bootstrap = true agentConfig.Server = true agentConfig.DataDir = "/tmp" agentConfig.Ports.HTTP = 8500 agentConfig.Ports.HTTPS = -1 //agentConfig.AdvertiseAddr = "127.0.0.1" //agentConfig.EnableUi = true agentConfig.Addresses.HTTP = "127.0.0.1" glog.Infof("Agent config: %+v", agentConfig) agent, err := agent.Create(agentConfig, writer) if err != nil { t.Fatalf("Error starting consul agent: %v", err) } </code></pre> <p>The resulting configuration on start looks like:</p> <pre><code>Agent config: &amp;{DevMode:true Bootstrap:true BootstrapExpect:0 Server:true Datacenter:dc1 DataDir:/tmp DNSRecursor: DNSRecursors:[] DNSConfig:{NodeTTL:0 NodeTTLRaw: ServiceTTL:map[] ServiceTTLRaw:map[] AllowStale:false EnableTruncate:false UDPAnswerLimit:3 MaxStale:5s MaxStaleRaw: OnlyPassing:false} Domain:consul. EncryptKey: LogLevel:INFO NodeName: ClientAddr:127.0.0.1 BindAddr:127.0.0.1 AdvertiseAddr: AdvertiseAddrs:{SerfLan:&lt;nil&gt; SerfLanRaw: SerfWan:&lt;nil&gt; SerfWanRaw: RPC:&lt;nil&gt; RPCRaw:} AdvertiseAddrWan: TranslateWanAddrs:false Ports:{DNS:8600 HTTP:8500 HTTPS:-1 RPC:8400 SerfLan:8301 SerfWan:8302 Server:8300} Addresses:{DNS: HTTP:127.0.0.1 HTTPS: RPC:} TaggedAddresses:map[] LeaveOnTerm:false SkipLeaveOnInt: &lt;nil&gt; Telemetry:{StatsiteAddr: StatsdAddr: StatsitePrefix:consul DisableHostname:false DogStatsdAddr: DogStatsdTags:[]} Protocol:2 EnableDebug:false VerifyIncoming:false VerifyOutgoing:false VerifyServerHostname:false CAFile: CertFile: KeyFile: ServerName: StartJoin:[] StartJoinWan:[] RetryJoin:[] RetryMaxAttempts:0 RetryInterval:30s RetryIntervalRaw: RetryJoinWan:[] RetryMaxAttemptsWan:0 RetryIntervalWan:30s RetryIntervalWanRaw: ReconnectTimeoutLan:0 ReconnectTimeoutLanRaw: ReconnectTimeoutWan:0 ReconnectTimeoutWanRaw: EnableUi:false UiDir: PidFile: EnableSyslog:false SyslogFacility:LOCAL0 RejoinAfterLeave:false CheckUpdateInterval:5m0s CheckUpdateIntervalRaw: ACLToken: ACLMasterToken: ACLDatacenter: ACLTTL:30s ACLTTLRaw: ACLDefaultPolicy:allow ACLDownPolicy:extend-cache Watches:[] DisableRemoteExec:false DisableUpdateCheck:false DisableAnonymousSignature:false HTTPAPIResponseHeaders:map[] AtlasInfrastructure: AtlasToken: AtlasACLToken: AtlasJoin:false AtlasEndpoint: AEInterval:1m0s DisableCoordinates:false SyncCoordinateRateTarget:64 SyncCoordinateIntervalMin:15s Checks:[] Services:[] ConsulConfig:&lt;nil&gt; Revision: Version: VersionPrerelease: WatchPlans:[] UnixSockets:{UnixSocketPermissions:{Usr: Grp: Perms:}} SessionTTLMin:0 SessionTTLMinRaw: Reap:&lt;nil&gt;} </code></pre> <p>Checking my open ports I can see that the agent is up but not listening for HTTP</p> <pre><code>storage.t 16820 felix 5u IPv4 469866 0t0 TCP localhost:8300 (LISTEN) storage.t 16820 felix 6u IPv4 469867 0t0 TCP localhost:8301 (LISTEN) storage.t 16820 felix 7u IPv4 469868 0t0 UDP localhost:8301 storage.t 16820 felix 8u IPv4 469869 0t0 TCP localhost:8302 (LISTEN) storage.t 16820 felix 9u IPv4 469870 0t0 UDP localhost:8302 </code></pre> <p>Every tip to get that running is appreciated :)</p> </div>

从Consul获得的具有持久连接的gRPC服务的客户端注册表

<div class="post-text" itemprop="text"> <p>I have a Go service which is pluggable and based on the plugin serve different purposes. At the start it's register the address and port into the Consul's service discovery and it's tags like <code>plugin1</code>, <code>plugin2</code>, <code>plugin3</code>, etc. </p> <p>On the client-side I want to connect to the services based on the plugin what it implements. I can get them from consul, call the <code>grpc.Dial</code> and pass it to the proto's client implementation. When I call the right endpoint I just close the connection and go on. </p> <p>The problem with this, the <code>grpc.Dial</code> can be a reusable connection, so not necessary to call it anytime when I want to connect to a service, but it's too dynamic to have a persistent connection to the services, because services could be removed or new services can appear. </p> <p>What is the best way to have persistent connection to the services based on this requirements/problems?</p> </div>

springloud+consul进行搭建分布式项目集群框架

推荐一些springcloud+consul做分布式集群的源码

Consul读取超时出错,实力不够,解决不了,请大神帮忙

![图片说明](https://img-ask.csdn.net/upload/201908/27/1566876212_98723.png)

关于consul启动的错误

![这个该怎么解决呀。。刚解压出来的。图片说明](https://img-ask.csdn.net/upload/201710/02/1506936390_415273.png)

在Docker HTTP运行状况检查上运行的Consul返回“对等连接重置”

<div class="post-text" itemprop="text"> <p>We are running consul through docker and using the HTTP health checks to a URL (<a href="https://10.1.24.68:5012/status" rel="nofollow">https://10.1.24.68:5012/status</a>) with a self-signed certificate. However, I get the following error:</p> <blockquote> <p>2016/06/10 10:29:42 [WARN] agent: http request failed '<a href="https://10.1.24.68:5012/status" rel="nofollow">https://10.1.24.68:5012/status</a>': Get <a href="https://10.1.24.68:5012/status" rel="nofollow">https://10.1.24.68:5012/status</a>: read tcp 10.3.2.11:55549-&gt;10.1.24.68:5012: read: connection reset by peer</p> </blockquote> <p>It works as well when we use the Script health check with the <code>wget</code> command but this is not ideal. <a href="https://github.com/hashicorp/consul/blob/14ec46b3cf8edf6fdd3f4bda8deacdfb6d4e9a73/command/agent/check.go#L426" rel="nofollow">This</a> is the line of code in Consul throwing the above error.</p> <p>When running the health check to a HTTP URL (<a href="http://localhost:5012/status" rel="nofollow">http://localhost:5012/status</a>) it works. Could this be a certificate issue? I've added our certificate to both <code>/etc/ssl/certs/ca-certificates.crt</code> and <code>/usr/share/local/ca-certificates.crt</code>.</p> <p>Halp!</p> </div>

springcloud使用consul作为注册中心时,所注册的服务在访问时是如何保证其负载均衡的?

在很多博客上看到一些关于consul的介绍以及注册实例,但是几乎没有服务的使用实例, 有介绍说使用Feign进行调用,后面试用轮询的方式,那么如果多个请求同时到达, 轮询的第一个服务会不会压力过大?想了解下关于consul到底是怎样实现负载均衡的,拜托了!

群集中n个Web服务器之间的文件同步

<div class="post-text" itemprop="text"> <p>There are <em>n</em> nodes in a web cluster. Files may be uploaded to any node and then must be distributed to every other node. This distribution does not have to happen in a transaction (in fact it must not, distributed transactions don't scale) and some latency is acceptable, although must be minimal. Conflicts can be resolved arbitrarily (typically last write wins) provided that the resolution is also distributed to all nodes so that eventually all nodes have the same set of files. Nodes can be added and removed dynamically without having to reconfigure existing nodes. There must be no single point of failure and no additional boxes required to solve this (such as RabbitMQ)</p> <p>I am thinking along the lines of using consul.io for dynamic configuration so that each node can refer to consul to determine what other nodes are available and writing a daemon (Golang) that monitors the relevant folders and communicates with other nodes using ZeroMQ. </p> <p>Feels like I would be re-inventing the wheel though. This is a common problem and I expect there are solutions available already that I don't know about? Or perhaps my approach is wrong and there is another way to solve this?</p> </div>

如何使用逗号连接领事模板的服务元数据

<div class="post-text" itemprop="text"> <p>Does anyone know how to concatenate strings from consul for consul-template? </p> <p>If I have a service 'foo' registered in Consul</p> <pre><code>{ "Node": "node1", "Address": "192.168.0.1", "Port": 3333 }, { "Node": "node2", "Address": "192.168.0.2", "Port": 4444 } </code></pre> <p>I would like consul-template to generate the following line:</p> <pre><code>servers=192.168.0.1:3333,192.168.0.2:4444/bogus </code></pre> <p>The following attempt does not work since it leaves a trailing comma <code>,</code></p> <pre><code>servers={{range service "foo"}}{{.Address}}{{.Port}},{{end}}/bogus # renders servers=192.168.0.1:3333,192.168.0.2:4444,/bogus # What I actually want servers=192.168.0.1:3333,192.168.0.2:4444/bogus </code></pre> <p>I know consul-template uses golang template syntax, but I simply cannot figure out the syntax to get this working. Its likely that I should use consul-template's <code>join</code> but how do I pass both <code>.Address</code> and <code>.Port</code> to <code>join</code>? This is just a trivial example, and I'm not using indexes intentionally since the number of services could be more than two. Any ideas?</p> </div>

Consul集群遇到Encrypti on is configured but remote state is not encrypted

我两台电脑启动consul,并加到同一个集群中,出现以下错误: 2019/12/19 16:12:35 [ERR] memberlist: Push/Pull with n2.dc1 failed: Encrypti on is configured but remote state is not encrypted。 有谁遇到同样的问题没有,麻烦提供下解决方案,谢谢!

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

我说我不会算法,阿里把我挂了。

不说了,字节跳动也反手把我挂了。

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 java.io 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...

立即提问
相关内容推荐