2024-12-12 10:34:01.492 WARN 1 --- [oundedElastic-4] o.s.c.l.core.RoundRobinLoadBalancer : No servers available for service: XXXXXXXXXXXXX
java.lang.IllegalStateException: No instances available for 10.142.244.11
at org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient.execute(BlockingLoadBalancerClient.java:79)
at org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor.intercept(LoadBalancerInterceptor.java:56)
at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93)
at com.enrising.ctsc.common.security.component.AiResourceServerAutoConfiguration.lambda$lbRestTemplate$0(AiResourceServerAutoConfiguration.java:51)
at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93)
at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:77)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:66)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:776)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)
at com.enrising.ctsc.purchase.filesystem.util.DfsUtilsService.downloadForStream(DfsUtilsService.java:63)
at com.enrising.ctsc.purchase.filesystem.util.DfsUtilsService.downloadForStream(DfsUtilsService.java:38)
at com.enrising.ctsc.purchase.filesystem.service.impl.FilingServiceImpl.historyFileUploadTask(FilingServiceImpl.java:397)
at com.enrising.ctsc.purchase.filesystem.service.impl.FilingServiceImpl$$FastClassBySpringCGLIB$$56694f8.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
at com.enrising.ctsc.purchase.filesystem.service.impl.FilingServiceImpl$$EnhancerBySpringCGLIB$$fccef0f.historyFileUploadTask(<generated>)
at com.enrising.ctsc.purchase.filesystem.controller.FilingController.historyFileUploadTask(FilingController.java:78)
at com.enrising.ctsc.purchase.filesystem.controller.FilingController$$FastClassBySpringCGLIB$$e3e5b0f6.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
一:由于我在某个服务中调用一个服务,结果服务报错No servers available for service: + ip地址
因为我这个服务是个微服务,然后我直接注入使用的 restTemplate对象。导致最终调用时候是在自己应用里面找对应的ip服务。默认认为自己应用中微服务之间的调用。
修改后的代码为:直接新建一个new RestTemplate()解决问题。
之前:网上看得案例包括有自己微服务调用需要将你调用的ip地址修改为对应的服务的注册名称才能调用。