Spring GemFire 引导 - 创建名称为 'continuousQueryListenerContainer' 的 bean 时出错

Spring Boot for GemFire - Error creating bean with name 'continuousQueryListenerContainer'

我正在使用 spring boot 2.5.6 并将 gemfire 与其集成。

在 PCF 上部署应用程序时出现异常:

创建名称为 'continuousQueryListenerContainer' 的 bean 在 class 路径资源 [org/springframework/data/gemfire/config/annotation/ContinuousQueryConfiguration.class] 中定义时出错:调用 init 方法失败;嵌套异常是 java.lang.IllegalArgumentException:未找到名称为 [DEFAULT] 的池

我用来支持 gemfire 的依赖项是:

            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-gemfire-starter</artifactId>
            <version>1.2.0.RELEASE</version>
        </dependency>

首先,Spring 启动 Apache Geode [以及可选的 VMware Tanzu (Pivotal) GemFire] (SBDG) 1.2.xbased onSpring引导2.2.x,不是2.5.x!所以不推荐这个组合。

是SBDG1.5.6based on Spring Boot 2.5.6, and the latest version in the Spring Boot 2.5.x / SBDG 1.5.x release series is currently, 1.5.7 (with Spring Boot 2.5.7).

此外,对于任何 major.minor版本(例如1.2)。

据推测,您仍在使用 SBDG 1.2,即使它是 now EOL, because you have a GemFire 9.8 cluster (?), on which SBDG 1.2 is based。或者,在你的情况下,PCF 中 PCC 集群的版本可能是基于 GemFire 9.8??

最后,您可以在 SBDG Wiki 中查看所有这些信息,Version Compatibility Matrix

顺便说一句,这个问题与@rupweb 在这个问题中遇到的问题没有什么不同,

但是,这个问题在 PCC 上下文中也有根本的不同,尤其是在使用 SBDG 时。 SBDG 从 PCC 环境(即 VCAP 应用程序和服务环境变量)中为客户端(SBDG 应用程序)派生 PCC 集群(Locators/Servers)连接元数据。然后在 configuring the Locators of all Pools defined. The SDG property generally refers to all Pools created, which is simply the "DEFAULT" Pool when setting up the ClientCache to begin with. Of course, the property can be specialized for specific "named" Pools (see here) 中继续进行,但是,这通常不是必需的。

无论如何,您可以继续 see in Spring Data for Apache Geode [and optionally, VMware Tanzu GemFire] (SDG) specifically, in the 2.2.0.RELEASE, on which SBDG 1.2.0.RELEASE is based,当应用程序部署到 PCF 时,SBDG 根据 spring.data.gemfire.pool.locators 属性 设置初始化“DEFAULT”池,连接到 PCC 集群。

在创建 ClientCache 实例时 GemFire/Geode 本身设置了“默认”Pool(SBDG 自动配置 默认;参见 here).

但是,这可能会因 2 个原因(可能是其他原因)而中断:

  1. 首先,如果您在 @SpringBootApplication class 或另一个 Spring @Configuration [上明确声明了 SDG @ClientCacheApplication 注释=135=],那么您实际上覆盖了 自动配置 。使用 SBDG 时不要这样做。如果您需要自定义 ClientCache 配置,请在 application.properties.

    中使用适当的属性
  2. 如果您自己显式 define/declare 一个 Pool (bean),那么 GemFire/Geode 会放弃创建“DEFAULT” Pool

当然,由于您没有共享任何应用程序配置片段,因此很难确定发生了什么。

我知道 SBDG 提供的 SDG/GemFire/Geode CQ 的自动配置工作正常,因为在 SBDG 测试套件中 Integration Test

NOTE: There is nothing particularly special about the imported STDG ClientServerIntegerationTestsConfiguration class (here) used by the GemFire client test configuration, other than coordinating the CacheServer port and client Pool port accordingly, given the port is dynamically generated. The client also connects directly to the CacheServer in the test, which is of no consequence.

您还可以尝试以下 2 种方法中的一种:

  1. 首先,您可以显式定义一个名为“DEFAULT”的 Pool bean,如下所示:
@Configuration
@EnablePool(name = "DEFAULT")
class AdditionalGemFireConfiguration {
  // ...
}

通过使用名为“DEFAULT”的 SDG 的 @EnablePool 注释,它将确保存在名为“DEFAULT”的 Pool。而且,因为 SBDG 一般指代所有池(使用 属性 spring.data.gemfire.pool.locators),那么“DEFAULT”Pool 应该选择来自 SBDG 的配置,而 SBDG 同样来自 VCAP使用 PCC 时 PCF 内的环境。

  1. 或者,您可以配置一个 BeanPostProcessor 来自定义 SDG ContinuousQueryListenerContainer bean auto-configured 由 SBDG,并设置自定义 Pool 名称,因此。

使用 SBDG 项目并遵循 docs (also see).

中描述的约定时,这两种方法都不是必需的

让我们从这些信息开始,并在必要时进行迭代。