调用接口时报错:com.netflix.client.ClientException

Blade 未结 1 1606

一、该问题的重现步骤是什么?

1.新建一个新的工程,将BladeX工程中的System,User,Auth,Gateway工程复制到该工程中

2.修改每个工程SpringBoot启动类中的服务名,如下所示:

@EnableBladeFeign
@Configuration
@EnableFeignClients({"org.springblade", "com.ai.apac.smartenv.system"})
@MapperScan({"org.springblade.**.mapper.**", "com.ai.apac.smartenv.**.mapper.**"})
@SpringCloudApplication
public class SystemApplication {

   public static void main(String[] args) {
      BladeApplication.run(ApplicationConstant.APPLICATION_SYSTEM_NAME, SystemApplication.class, args);
   }

}

 其中ApplicationConstant类定义如下:

public interface ApplicationConstant {

    String BASE_PACKAGES = "com.ai.apac.smartenv";
    String APPLICATION_NAME_PREFIX = "smartenv-";
    String APPLICATION_SYSTEM_NAME = "smartenv-system";
    String APPLICATION_USER_NAME = "smartenv-user";
    String APPLICATION_AUTH_NAME = "smartenv-auth";
    String APPLICATION_GATEWAY_NAME = "smartenv-gateway";

}

3. 启动所有工程,在nacos上能看到如下结果

image.png

4.在Swagger上调用字典查询接口,接口请求如下:

image.png

二、你期待的结果是什么?实际看到的又是什么?

期望返回正确的结果,但是接口返回如下信息:

{
  "code": 500,
  "success": false,
  "data": {},
  "msg": "nested exception is org.apache.ibatis.exceptions.PersistenceException: \n### Error querying database.  Cause: java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: blade-system\n### The error may exist in com/ai/apac/smartenv/system/mapper/DictBizMapper.java (best guess)\n### The error may involve com.ai.apac.smartenv.system.mapper.DictBizMapper.selectPage\n### The error occurred while executing a query\n### Cause: java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: blade-system"
}


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

目前使用2.2.2.Release版本,在Mac操作系统上


四、请提供详细的错误堆栈信息,这很重要。

后台错误堆栈信息如下:

r$Worker.run(ThreadPoolExecutor.java:617)
 at java.lang.Thread.run(Thread.java:745)


五、若有更多详细信息,请在下面提供。



1条回答
  • 2020-01-10 08:32

    已解决,FeginClient接口类也需要改,如下所示

    @FeignClient(
       value = ApplicationConstant.APPLICATION_SYSTEM_NAME,
       fallback = IDataScopeClientFallback.class
    )
    public interface IDataScopeClient


    0 讨论(0)
提交回复