首页 > 解决方案 > Springboot Couchbase 应用程序无法部署在 windows 中

问题描述

我正在开发一个 Springboot 应用程序,它连接到远程 Couchbase 服务器以获取数据。该应用程序在我机器上的本地 Couchbase 服务器上运行良好。但是当我为远程数据库配置 API 属性时,它会抛出 java.util.concurrent.TimeoutException。以下是我的错误日志。

2020-08-31 08:50:50.596  WARN 12692 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileUploadController': Unsatisfied dependency expressed through field 'predictionService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'predictionServiceImpl': Unsatisfied dependency expressed through field 'predictionDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'predictionDaoImpl': Unsatisfied dependency expressed through field 'predictionRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'couchbaseRepositoryOperationsMapping' defined in class path resource [com/example/couchbaseService/Configuration/CouchbaseConfiguration.class]: Unsatisfied dependency expressed through method 'repositoryOperationsMapping' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseTemplate' defined in class path resource [com/example/couchbaseService/Configuration/CouchbaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.couchbase.core.CouchbaseTemplate]: Factory method 'couchbaseTemplate' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseBucket' defined in class path resource [com/example/couchbaseService/Configuration/CouchbaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.couchbase.client.java.Bucket]: Factory method 'couchbaseClient' threw exception; nested exception is java.lang.RuntimeException: java.util.concurrent.TimeoutException
2020-08-31 08:50:50.642  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown kvIoPool: success
2020-08-31 08:50:50.645  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown viewIoPool: success
2020-08-31 08:50:50.652  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown queryIoPool: success
2020-08-31 08:50:50.656  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown searchIoPool: success
2020-08-31 08:50:50.659  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown Core Scheduler: success
2020-08-31 08:50:50.659  INFO 12692 --- [       Thread-5] c.c.client.core.env.CoreEnvironment      : Shutdown Netty: success
2020-08-31 08:50:50.662  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown Runtime Metrics Collector: success
2020-08-31 08:50:50.666  INFO 12692 --- [           main] c.c.client.core.env.CoreEnvironment      : Shutdown Latency Metrics Collector: success
2020-08-31 08:50:50.683  INFO 12692 --- [      cb-io-1-2] c.c.client.core.endpoint.Endpoint        : [][KeyValueEndpoint]: Got notified from Channel as inactive, attempting reconnect.
2020-08-31 08:50:50.690  INFO 12692 --- [entExecutor-2-2] c.c.client.core.env.CoreEnvironment      : Shutdown IoPool: success
2020-08-31 08:50:50.703  INFO 12692 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

由于我无法找出原因,我在不同的 Windows 机器上测试了 API,所有尝试都给出了相同的错误。但是,API 在 MacOS 机器上成功启动并且工作正常。我正在使用 Java 11 和 Couchbase 企业版 6.5.0。我的springboot版本是2.0.1。任何人都可以帮助我找出原因吗?谢谢你。

标签: javaspring-bootcouchbase

解决方案


如果您声称它可以在 Mac 上运行,并且代码没有问题,那么问题可能出在您的公司网络策略上。通常,公司对 Windows 的配置文件与 Mac 的配置文件不同。它也可能是防火墙/防病毒软件,它阻止了 Mac 没有的 PC 上的传出流量。

为了验证这个理论,在你的 PC 上本地运行一个 Couchbase 服务器,看看你是否可以连接到它。


推荐阅读