且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Geode/GemFire无法创建gemfireCache bean错误:Spring Boot v2.1.3-GemFire启动器1.1.0.RELEASE

更新时间:2022-03-24 23:54:10

@ Madmax-您要引用哪个版本的兼容性矩阵?这是官方"

@Madmax- To which version compatibility matrix do you refer? This is the "official" version compatibility matrix.

如您所见,SBDG 1.1.x的最新版本是1.1.6.RELEASE,它是

As you can see, the latest version of SBDG 1.1.x is 1.1.6.RELEASE, which is based on Spring Boot 2.1.13.RELEASE.

如果我们回到SBDG 1.1.0.RELEASE,我们会看到它是

If we go back to SBDG 1.1.0.RELEASE we see that it was based on Spring Boot 2.1.7.RELEASE. This creates a cascading effect on transitive dependencies.

由于SBDG 1.1.0.RELEASE是基于Spring Boot 2.1.7.RELEASE的,这意味着SBDG 1.1.0.RELEASE也需要Spring Data Lovelace-SR10(即包含 Apache Geode和Pivotal GemFire(SDG)2.1.10.RELEASE的Spring数据.因此,SBDG 1.1.0.RELEASE对Spring Boot 2.1.7.RELEASE和SDG 2.1.10.RELEASE的最低要求.

Since SBDG 1.1.0.RELEASE is based on Spring Boot 2.1.7.RELEASE, that means SBDG 1.1.0.RELEASE also requires Spring Data Lovelace-SR10 (which is pulled in by Boot 2.1.7.RELEASE). Spring Data Lovelace-SR10 (here) includes Spring Data for Apache Geode and Pivotal GemFire (SDG) 2.1.10.RELEASE. Therefore, SBDG 1.1.0.RELEASE has a minimum requirement of Spring Boot 2.1.7.RELEASE and SDG 2.1.10.RELEASE.

如果我们对Spring Boot 2.1.3.RELEASE重复此练习,则会看到Boot 此处),其中

If we repeat this exercise for Spring Boot 2.1.3.RELEASE, we see that Boot pulls in Spring Data Lovelace-SR5 (here), which includes SDG 2.1.5.RELEASE. SDG 2.1.5.RELEASE does not meet the minimum requirement for SBDG 1.1.0.RELEASE.

注意,这一直延伸到核心Spring Framework本身,因为Spring Boot也基于并引入了核心Spring Framework,并且Spring Data也基于核心Spring Framework.因此,所有版本都必须对齐.

Note, this extends all the way down to the core Spring Framework itself, since Spring Boot is based on and pulls in the core Spring Framework as well, and Spring Data is also based on the core Spring Framework. Therefore, all the versions must align.

通常,您不能将不兼容的版本串在一起.如果是版本兼容性矩阵(或更确切地说是SBDG gradle.properties文件,

In general, you cannot string together incompatible versions. If the version compatibility matrix (or more technically, the SBDG gradle.properties file, for example) states a particular version of a direct or transitive dependency, then that version of the dependency is expected and required.

话虽如此,我基于Spring Boot 2.1.3.RELEASE使用SDDG 1.1.0.RELEASE设置了一个示例/测试项目,以查看是否可以重现您的错误.我做到了!但是,我得到了更精确的错误消息:

Having said that, I setup an example/test project with SDDG 1.1.0.RELEASE based on Spring Boot 2.1.3.RELEASE to see if I could reproduce your error. I did! However, I got a more precise error message:

Caused by: java.lang.AbstractMethodError: Receiver class org.springframework.geode.boot.autoconfigure.CacheNameAutoConfiguration$$Lambda$327/0x0000000800e48c40 does not define or inherit an implementation of the resolved method 'abstract void configure(java.lang.String, org.springframework.data.gemfire.client.ClientCacheFactoryBean)' of interface org.springframework.data.gemfire.config.annotation.ClientCacheConfigurer.
    at org.springframework.data.gemfire.client.ClientCacheFactoryBean.lambda$null$0(ClientCacheFactoryBean.java:118)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1510)
    at org.springframework.data.gemfire.client.ClientCacheFactoryBean.lambda$new$1(ClientCacheFactoryBean.java:117)
    at org.springframework.data.gemfire.client.ClientCacheFactoryBean.lambda$applyClientCacheConfigurers$2(ClientCacheFactoryBean.java:156)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.springframework.data.gemfire.client.ClientCacheFactoryBean.applyClientCacheConfigurers(ClientCacheFactoryBean.java:156)
    at org.springframework.data.gemfire.client.ClientCacheFactoryBean.applyClientCacheConfigurers(ClientCacheFactoryBean.java:142)
    at org.springframework.data.gemfire.client.ClientCacheFactoryBean.applyCacheConfigurers(ClientCacheFactoryBean.java:129)
    at org.springframework.data.gemfire.CacheFactoryBean.afterPropertiesSet(CacheFactoryBean.java:177)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1821)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758)
    ... 29 more

进一步调查后,我找到了问题所在.

After further investigation, I have traced down the problem.

SBDG CacheNameAutoConfiguration

The SBDG CacheNameAutoConfiguration class uses the SDG ClientCacheConfigurer interface to configure the "name" of the GemFire/Geode cache instance.

SDG ClientCacheConfigurer接口为). 尽管它们在逻辑上是相同的接口,但是(方法分辨率)字节码无疑是不同的,因此JRE无法解析该方法.

The SDG ClientCacheConfigurer interface was defined as this in SDG 2.1.5.RELEASE, which again is pulled in by Spring Boot 2.1.3.RELEASE. However, in SDG2.1.10.RELEASE, I [redefined][13] theClientCacheConfigurerinterface (now, an@FunctionalInterfaceas well) in terms of a baseConfigurer` interface (this). While they are the same interface logically, the (method resolution) byte code is no doubt different and therefore, the JRE cannot resolve the method.

您可以尝试从Spring Boot(自动)配置中排除CacheNameAutoConfiguration类,如下所示:

You could try excluding the CacheNameAutoConfiguration class from your Spring Boot (auto) configuration, like so:

@SpringBootApplication(exclude = CacheNameAutoConfiguration.class)
class PccTestApplication { ... }

但是,SBDG在SBDG的 auto-configuraiton 的几个区域中广泛使用ClientCacheConfigurer @FunctionalInterface,以便自定义SDG和GemFire/Geode的配置,以方便使用惯例代表用户的目的.

However, SBDG makes liberal use of the ClientCacheConfigurer @FunctionalInterface in several areas of SBDG's auto-configuraiton in order to customize the configuration of SDG, and GemFire/Geode, for conventions and convenience purposes on-behalf of the user.

实际上,我必须排除这两个SBDG 自动配置类,才能使您的示例/测试正常运行.

In fact, I had to exclude both of these SBDG auto-configuration classes to get your example/test working correctly.

@SpringBootApplication(exclude = { 
    CacheNameAutoConfiguration.class, 
    ContinuousQueryAutoConfiguration.class 
})
class PccTestApplication { ... }

有关禁用自动配置的更多详细信息,请参见此处.

For more details on disable auto-configuration, see here and here.

但是,老实说,我不建议使用方法作为答案.

However, I don't recommend approach as the answer, honestly.

您应该使用兼容版本,即SBDG 1.1.0.RELEASE实际上应该与基准Spring Boot版本2.1.7.RELEASE配对.

It is pertinent that you use compatible versions, i.e. SBDG 1.1.0.RELEASE really ought to be paired with the baseline Spring Boot version 2.1.7.RELEASE.

更是如此,您应该强烈考虑在1.1.x行中将SBDG 1.1.6.RELEASE与Spring Boot 2.1.13.RELEASE一起使用.

Even more so, you should strongly consider using SBDG 1.1.6.RELEASE in the 1.1.x line with Spring Boot 2.1.13.RELEASE.

如另一篇SO帖子所述,带有Spring Boot 2.1.14.RELEASE的SBDG 1.1.7.RELEASE将于本周四4/30到期.有关更多信息,请参见Spring 发布日历.

As mentioned in another SO post, SBDG 1.1.7.RELEASE with Spring Boot 2.1.14.RELEASE is due this Thursday, 4/30. See the Spring release calendar for more information.

如果可能的话,我还建议进一步升级到带有SBDG 1.2.6.RELEASE的Spring Boot 2.2.x(当前为2.2.6.RELEASE).

I'd also recommend to go even further and upgrade to Spring Boot 2.2.x (currently, 2.2.6.RELEASE) with SBDG 1.2.6.RELEASE if at all possible.

希望这会有所帮助!