spring-data-redis版本冲突引发的问题
生活随笔
收集整理的這篇文章主要介紹了
spring-data-redis版本冲突引发的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.昨天在maven build項目中發現有個問題,如下所示
java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;)Vat org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.<init>(AbstractRepositoryConfigurationSourceSupport.java:68)at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.getConfigurationSource(AbstractRepositoryConfigurationSourceSupport.java:67)at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58)at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:352)at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143)at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320)at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)at com.ppdai.realtime.datachannel.mq.MessageQueueApp.main(MessageQueueApp.java:20)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:558)at java.lang.Thread.run(Thread.java:748)原因分析:
https://github.com/spring-projects/spring-boot/commit/5a4ef50ef1d71f1a42edaee309b3e04fb754b13a
因為spring boot和sping-data-redis版本不匹配導致的,spring-data-redis使用?1.8.1.RELEASE版本? 依賴
<dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-keyvalue</artifactId><version>1.2.1.RELEAS</version></dependency>
依賴
<dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-commons</artifactId><version>1.13.1.RELEASE</version> </dependency>如下圖所示 這是spring-boot 1.5.9.Release版本的函數
而spring-data-commons中構造函數如下
二種解決方案,
第一 將spring-boot-autoconfig版本從1.5.9.RELEASE降低為1.5.2
或者將spring-data-commons版本從1.13.1.RELEASE升到1.13.7.RELEASE
完結。。
另外附上一個問題
Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.RepositoryConfigurationSource Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.RepositoryConfigurationSourceat java.net.URLClassLoader.findClass (URLClassLoader.java:381)at java.lang.ClassLoader.loadClass (ClassLoader.java:424)at java.lang.ClassLoader.loadClass (ClassLoader.java:357)at java.lang.Class.getDeclaredConstructors0 (Native Method)at java.lang.Class.privateGetDeclaredConstructors (Class.java:2671)at java.lang.Class.getConstructor0 (Class.java:3075)at java.lang.Class.getDeclaredConstructor (Class.java:2178)at org.springframework.beans.BeanUtils.instantiateClass (BeanUtils.java:102)at org.springframework.beans.BeanUtils.instantiateClass (BeanUtils.java:125)at org.springframework.context.annotation.ConfigurationClassParser.processImports (ConfigurationClassParser.java:585)at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass (ConfigurationClassParser.java:293)at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass (ConfigurationClassParser.java:244)at org.springframework.context.annotation.ConfigurationClassParser.processImports (ConfigurationClassParser.java:595)at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors (ConfigurationClassParser.java:538)at org.springframework.context.annotation.ConfigurationClassParser.parse (ConfigurationClassParser.java:184)at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions (ConfigurationClassPostProcessor.java:308)at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry (ConfigurationClassPostProcessor.java:228)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors (PostProcessorRegistrationDelegate.java:270)at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors (PostProcessorRegistrationDelegate.java:93)at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors (AbstractApplicationContext.java:686)at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:524)at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh (EmbeddedWebApplicationContext.java:122)at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:693)at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:360)at org.springframework.boot.SpringApplication.run (SpringApplication.java:303)原因
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration]; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/config/RepositoryConfigurationSource因為spring-boot autoconfig需要RedisRepositoriesAutoConfiguration? 這個類找不到,解決方案
添加依賴
<dependency><groupId>org.springframework.data</groupId><artifactId>spring-data-commons</artifactId><version>1.13.7.RELEASE</version> </dependency>因為spring
轉載于:https://www.cnblogs.com/zhengwangzw/p/9956874.html
總結
以上是生活随笔為你收集整理的spring-data-redis版本冲突引发的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Fetch API HTTP请求实用指南
- 下一篇: Ubuntu 编译安装python3.7