Spring Data GemFire 2.0.1.RELEASE引发初始化错误 [英] Spring Data GemFire 2.0.1.RELEASE is throwing an Initialization Error

查看:94
本文介绍了Spring Data GemFire 2.0.1.RELEASE引发初始化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初,我的应用程序在 spring-data-gemfire 1.9.7.RELEASE 上运行良好.但是,升级到 spring-data-gemfire 2.0.1.RELEASE 后,我的应用程序无法启动,并引发初始化错误,如下所示:

C:\ Dev \ projects \ JavaWebClient \ web \ target> java -jar web-0.0.1-SNAPSHOT.jar

. ____ _ __ _ _
/\/ ' __ _ ()_ __ __ __ _ \ \ \ \
(()_
|'_ |' | |'/`| \ \ \ \
\/
)| | )| | | | | || ( | | |))))
'| ____ |
| |. | | | | __,|////
======== | _ | ============= | ___/=///_/
:: Spring Boot ::(v1.5.8.RELEASE)

[info 2017/11/15 19:07:23.999 EAT tid = 0x1]开始 MY-PC上具有PID 13804的JavaWebClientApplication v0.0.1-SNAPSHOT (C:\ Dev \ projects \ JavaWebClient \ web \ target \ web-0.0.1-SNAPSHOT.jar 由爱德华兹在C:\ Dev \ projects \ JavaWebClient \ web \ target中启动

[info 2017/11/15 19:07:24.019 EAT tid = 0x1]没有有效的个人资料 设置,返回默认配置文件:默认

[info 2017/11/15 19:07:24.812 EAT tid = 0x1]刷新 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: 启动日期[EAT 2017年11月15日星期三19:07:24];语境的根源 等级

[错误2017/11/15 19:07:25.892 EAT tid = 0x1]应用程序启动 失败的java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; 在org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension.registerBeansForRoot(GemfireRepositoryConfigurationExtensi on.java:120) 在org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:116) 在org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport.registerBeanDefinitions(RepositoryBeanDefinitionRegistrarSupport. Java:83) 在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda $ loadBeanDefinitionsFromRegistrars $ 0(ConfigurationClassBeanDefini tionReader.java:360) 在java.util.LinkedHashMap.forEach(未知来源) 在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReade r.java:359) 在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefiniti onReader.java:144) 在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)处 在org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)处 在org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)处 在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.ja va:273) 在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)处 在org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) 在org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:303) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) 在com.nftconsult.gemfire.web.JavaWebClientApplication.main(JavaWebClientApplication.java:173) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) 在java.lang.reflect.Method.invoke(未知来源) 在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 在org.springframework.boot.loader.Launcher.launch(Launcher.java:87) 在org.springframework.boot.loader.Launcher.launch(Launcher.java:50) 在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

[info 2017/11/15 19:07:25.897 EAT tid = 0x1]闭幕 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: 启动日期[EAT 2017年11月15日星期三19:07:24];语境的根源 等级

[警告2017/11/15 19:07:25.901 EAT tid = 0x1]引发异常 从LifecycleProcessor上下文关闭 java.lang.IllegalStateException:LifecycleProcessor未初始化- 通过上下文调用生命周期方法之前,请先调用刷新": org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: 启动日期[EAT 2017年11月15日星期三19:07:24];上下文层次结构的根 在org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:433) 在org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1004) 在org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:963) 在org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:314) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) 在com.nftconsult.gemfire.web.JavaWebClientApplication.main(JavaWebClientApplication.java:173) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) 在java.lang.reflect.Method.invoke(未知来源) 在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 在org.springframework.boot.loader.Launcher.launch(Launcher.java:87) 在org.springframework.boot.loader.Launcher.launch(Launcher.java:50) 在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

[错误2017/11/15 19:07:25.905 EAT tid = 0x1]销毁方法 豆与名字 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory '引发异常java.lang.IllegalStateException: ApplicationEventMulticaster未初始化-之前调用刷新" 通过上下文多播事件:org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e6c3152: 启动日期[EAT 2017年11月15日星期三19:07:24];上下文层次结构的根 在org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:420) 在org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:95)处 在org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:240) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:576) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:552) 在org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:953) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:521) 在org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:227) 在org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:960) 在org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1035) 在org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1011) 在org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:963) 在org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:314) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) 在com.nftconsult.gemfire.web.JavaWebClientApplication.main(JavaWebClientApplication.java:173) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) 在java.lang.reflect.Method.invoke(未知来源) 在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) 在org.springframework.boot.loader.Launcher.launch(Launcher.java:87) 在org.springframework.boot.loader.Launcher.launch(Launcher.java:50) 在org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

C:\ Dev \ projects \ JavaWebClient \ web \ target>

解决方案

不足为奇,因为您的 Spring 应用程序基于 Spring Boot 1.5.8.RELEASE,但并非基于明确说明如何将 Spring Data GemFire 依赖关系从1.9.7.RELEASE升级到2.0.1.RELEASE.

问题是,您引入了 Spring Data Commons 的不兼容版本以及我怀疑其他几个 Spring 依赖项(例如,核心 Spring Framework ),因为您的应用程序植根于 Spring Boot 1.5.8.RELEASE.因此,出现 java.lang.NoSuchMethodError 错误...

java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; 
at org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension.registerBeansForRoot(GemfireRepositoryConfigurationExtensi on.java:120)

首先,您需要了解所有 Spring数据模块(请参阅"主要模块","社区模块"和"相关模块",以及有关"发布培训"的部分SD项目页面)基于 Spring Data Commons 和核心 Spring Framework 的特定版本构建.您不能仅升级1个依赖项,而不必期望升级其他依赖项.

SD发行培训(例如 英文 Kay )均基于特定版本的 Spring Data Commons 和核心 Spring框架.例如,使用SD Kay ,请参阅" 核心主题 "和"

java.lang.NoSuchMethodError之所以特别出现,是因为您使用的是 Spring Data Commons 的不兼容版本(即 Ingalls 的SDC 1.13.8.RELEASE,即放入 Spring Boot 1.5.x )和 Spring Data GemFire 2.0.1.RELEASE组成,其中 org.springframework.data.repository.config.RepositoryConfigurationSource )是 Spring Data Commons 类.显然 Spring IO指南 (对于也一样还要注意我的依赖性.

Gradle 有点棘手,但是您可以看到新的构建文件 解决方案

Not surprising since your Spring application is based on Spring Boot 1.5.8.RELEASE and it isn't clear how you specifically upgraded the Spring Data GemFire dependency from 1.9.7.RELEASE to 2.0.1.RELEASE.

The problem is, you are pulling in an incompatible version of Spring Data Commons as well as, and I suspect, several other Spring dependencies (e.g. the core Spring Framework) since your applications is rooted in Spring Boot 1.5.8.RELEASE. Hence the java.lang.NoSuchMethodError error...

java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; 
at org.springframework.data.gemfire.repository.config.GemfireRepositoryConfigurationExtension.registerBeansForRoot(GemfireRepositoryConfigurationExtensi on.java:120)

First, you need to understand that all Spring Data modules (see "Main modules", "Community modules" and "Related modules" and the section about the "Release train" on the SD project page) build on a particular version of both Spring Data Commons and the core Spring Framework. You cannot simply upgrade 1 dependency and not expect to have to upgrade others.

The SD Release Trains (such as Ingalls or Kay) are all based on a particular version of Spring Data Commons and the core Spring Framework. For instance, with SD Kay, see "Core themes" and "Participating modules".

The java.lang.NoSuchMethodError is specifically occurring because you are using an incompatible version of Spring Data Commons (i.e. SDC 1.13.8.RELEASE from Ingalls, which is pulled in by Spring Boot 1.5.x) with Spring Data GemFire 2.0.1.RELEASE, which comes from SD Kay, and expects SDC 2.0.x.RELEASE.

This class, (i.e. org.springframework.data.repository.config.RepositoryConfigurationSource) is a Spring Data Commons class. Clearly the method signature (i.e. getAttribute(:String):String) in SDC 1.13.8 (Ingalls) for the method in question is not what SDG 2.0.1.RELEASE expects (i.e. getAttribute(:String):Optional<String>), which comes from SDC 2.0.1.RELEASE.

There is a reason why Spring Boot, and by extension, the Spring IO Platform, provide a curated and harmonized set of dependencies that have all been tested and proven to work together. When you deviate from the prescribed dependencies, you need to be mindful of this.

Technically, only the upcoming Spring Boot 2.0 release will be based on SD Kay.

However, if you do need a GA release of Spring Boot (i.e. 1.5.8.RELEASE, the current latest) and wish to use Spring Data GemFire 2.0.1.RELEASE, or Kay-SR1, then fortunately you are in luck!

I too wanted to use Spring Data Kay with the latest GA version of Spring Boot (i.e. 1.5.8.RELEASE) in the Spring IO Guides (for instance) to showcase the new features in Spring Data GemFire 2.0.x Kay, since many things have changed for the better (like this).

I was able to get this to work, but I need to set specific things in the Maven (or Gradle) build file, such as overriding the dependency versions of SD and the core Spring Framework managed by Spring Boot (specifically this, and this). Note this as well. Also note my dependencies.

Gradle is a bit more tricky, but you can see the new build file here and compare it with the previous version here.

Anyway, keep these things in mind the next time you are wrangling dependency versions, which is the whole reason why Spring IO Platform was created in the first place, to manage all the dependencies and dependencies of dependencies (i.e. transitive dependencies) when possible overlap/conflicts occur (since certain transitive dependencies will have the same dependencies), etc, etc.

Hope this helps!

Regards, -j

这篇关于Spring Data GemFire 2.0.1.RELEASE引发初始化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆