Springboot Couchbase Application无法在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。有人可以帮我找出原因吗?谢谢。

解决方法

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

要验证这一理论,请在PC上本地运行Couchbase服务器,然后查看是否可以连接到它。